Bluemix 中的 Watson Text-to-Speech 服务是否适用于移动应用程序?
Does the Watson Text-to-Speech service in Bluemix work for mobile apps?
为什么 Bluemix 上的 Watson Text-To-Speech 服务不适用于移动设备?这是来自服务器的输出流数据的常见问题吗?谢谢!
编辑:对不起,有人完全改变了我的问题。我说的是文字转语音
Watson Speech-To-Text 服务是 REST API。您需要从您的移动应用程序调用 REST API。有关 REST API 的更多信息,请查看 out the API docs.
Text To Speech 在 Android 中有效,并且有一个 SDK 可供您使用。
http://watson-developer-cloud.github.io/java-wrapper/
例如,要获得所有你能做的声音:
import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech;
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceSet;
TextToSpeech service = new TextToSpeech();
service.setUsernameAndPassword("<username>", "<password>");
VoiceSet voices = service.getVoices();
System.out.println(voices);
其中 username
和 password
是您在绑定服务时在 Bluemix 中获得的凭据。您可以通过查看 javadocs here.
了解有关 Text to Speech 方法的更多信息
它是我今天发布的,所以如果您发现任何问题请告诉我。
不清楚您是在询问语音到文本还是反之亦然。上面的大部分问题都涵盖了 speech to text ,可以在 Watson 站点上引用 -
http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/speech-to-text.html
Speech to Text 服务将人声转换为书面文字。这种易于使用的服务使用机器智能将有关语法和语言结构的信息与音频信号的组成知识相结合,以生成更准确的转录。转录会不断发送回客户端,并在听到更多语音时进行追溯更新。可以针对不同的语言以及特定领域训练识别模型。
如果您查看此 github 项目 https://github.com/FarooqMulla/BluemixExample/tree/master,它使用旧版 SDK
有一个使用实时语音转文本的示例 api,它将音频数据包发送到 bluemix 并实时接收回转录的字符串。
请注意,自 2016 年 1 月 22 日起,基于 Swift 的新 SDK 已因该特定功能而损坏。
如果您想在 iOS 设备上使用 Watson Text-To-Speech,使用 Watson-Developer-Cloud SDK for iOS - you might checkout the example on my blumarek.blogspot 可能会很方便,只需在 XCode 7.3+ 中构建一个应用即可:
第一步,使用carthage获取所有依赖:
(在项目根目录下创建一个文件cartfile和运行命令carthage update --platform iOS)
$ cat > cartfile
# cartfile contents
github "watson-developer-cloud/ios-sdk"
然后您需要将框架添加到 XCode 项目 - 检查步骤 3:将 SDK 添加到我的 blumareks.blogpost
上的 Xcode 项目
第 2 步。添加代码以调用 Watson TTS 并利用 AVFoundation
(不推荐使用 AVFoundation):
- 不要忘记在 Bluemix.net 中添加 Watson TTS 服务并从中获取凭据:
{
"credentials": {
"url": "https://stream.watsonplatform.net/text-to-speech/api",
"username": "<service User name>",
"password": "<password>"
}
}
而且代码很简单:
import UIKit
//adding Watson Text to Speech
import WatsonDeveloperCloud
//adding AVFoundation
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var speakText: UITextField!
override func viewDidLoad() {...}
override func didReceiveMemoryWarning() {...}
@IBAction func speakButtonPressed(sender: AnyObject) {
NSLog("speak button pressed, text to say: " + speakText.text!)
//adding Watson service
let service = TextToSpeech(username: "<service User name>", password: "<password>")
service.synthesize(speakText.text!)
{(data, error) in
do {
let audioPlayer = try AVAudioPlayer(data: data!)
audioPlayer.prepareToPlay()
audioPlayer.play()
sleep(10) //the thread needs to live long enough to say your text
} catch {
NSLog("something went terribly wrong")
}
}}}
为什么 Bluemix 上的 Watson Text-To-Speech 服务不适用于移动设备?这是来自服务器的输出流数据的常见问题吗?谢谢!
编辑:对不起,有人完全改变了我的问题。我说的是文字转语音
Watson Speech-To-Text 服务是 REST API。您需要从您的移动应用程序调用 REST API。有关 REST API 的更多信息,请查看 out the API docs.
Text To Speech 在 Android 中有效,并且有一个 SDK 可供您使用。
http://watson-developer-cloud.github.io/java-wrapper/
例如,要获得所有你能做的声音:
import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech;
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceSet;
TextToSpeech service = new TextToSpeech();
service.setUsernameAndPassword("<username>", "<password>");
VoiceSet voices = service.getVoices();
System.out.println(voices);
其中 username
和 password
是您在绑定服务时在 Bluemix 中获得的凭据。您可以通过查看 javadocs here.
它是我今天发布的,所以如果您发现任何问题请告诉我。
不清楚您是在询问语音到文本还是反之亦然。上面的大部分问题都涵盖了 speech to text ,可以在 Watson 站点上引用 -
http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/speech-to-text.html
Speech to Text 服务将人声转换为书面文字。这种易于使用的服务使用机器智能将有关语法和语言结构的信息与音频信号的组成知识相结合,以生成更准确的转录。转录会不断发送回客户端,并在听到更多语音时进行追溯更新。可以针对不同的语言以及特定领域训练识别模型。
如果您查看此 github 项目 https://github.com/FarooqMulla/BluemixExample/tree/master,它使用旧版 SDK
有一个使用实时语音转文本的示例 api,它将音频数据包发送到 bluemix 并实时接收回转录的字符串。
请注意,自 2016 年 1 月 22 日起,基于 Swift 的新 SDK 已因该特定功能而损坏。
如果您想在 iOS 设备上使用 Watson Text-To-Speech,使用 Watson-Developer-Cloud SDK for iOS - you might checkout the example on my blumarek.blogspot 可能会很方便,只需在 XCode 7.3+ 中构建一个应用即可:
第一步,使用carthage获取所有依赖:
(在项目根目录下创建一个文件cartfile和运行命令carthage update --platform iOS)
$ cat > cartfile
# cartfile contents
github "watson-developer-cloud/ios-sdk"
然后您需要将框架添加到 XCode 项目 - 检查步骤 3:将 SDK 添加到我的 blumareks.blogpost
上的 Xcode 项目第 2 步。添加代码以调用 Watson TTS 并利用 AVFoundation
(不推荐使用 AVFoundation): - 不要忘记在 Bluemix.net 中添加 Watson TTS 服务并从中获取凭据:
{
"credentials": {
"url": "https://stream.watsonplatform.net/text-to-speech/api",
"username": "<service User name>",
"password": "<password>"
}
}
而且代码很简单:
import UIKit
//adding Watson Text to Speech
import WatsonDeveloperCloud
//adding AVFoundation
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var speakText: UITextField!
override func viewDidLoad() {...}
override func didReceiveMemoryWarning() {...}
@IBAction func speakButtonPressed(sender: AnyObject) {
NSLog("speak button pressed, text to say: " + speakText.text!)
//adding Watson service
let service = TextToSpeech(username: "<service User name>", password: "<password>")
service.synthesize(speakText.text!)
{(data, error) in
do {
let audioPlayer = try AVAudioPlayer(data: data!)
audioPlayer.prepareToPlay()
audioPlayer.play()
sleep(10) //the thread needs to live long enough to say your text
} catch {
NSLog("something went terribly wrong")
}
}}}