繁体   English   中英

Bluemix中的Watson Text-to-Speech服务是否适用于移动应用程序?

[英]Does the Watson Text-to-Speech service in Bluemix work for mobile apps?

为什么Bluemix上的Watson Text-To-Speech服务在移动设备上不起作用? 这是来自服务器的输出流数据的常见问题吗? 谢谢!

编辑:对,有人完全改变了我的问题。 我说的是“文字转语音”

Watson语音转文本服务是REST API。 您需要从移动应用程序调用REST API。 有关REST API的更多信息,请查阅API文档

“文字转语音”可在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);

其中的usernamepassword是您绑定服务时在Bluemix中获得的凭证。 您可以通过此处的javadocs了解有关“文本到语音”方法的更多信息。

它已于今天发布,我做到了,因此,如果您发现任何问题,请告诉我。

如果您想在iOS设备上使用Watson Text-To-Speech,可以使用iOS的Watson-Developer-Cloud SDK方便使用-您可以在我的blumarek.blogspot查看示例,只需在XCode 7.3+中构建一个应用即可:

步骤1.使用迦太基获取所有依赖项:

(在项目根目录中创建文件cartfile并运行命令carthage update --platform iOS

$ cat > cartfile
# cartfile contents
github "watson-developer-cloud/ios-sdk"

然后需要将框架添加到XCode项目-检查步骤3:在我的blumareks.blogpost上将SDK添加到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")
        }
}}}

目前尚不清楚您是在问文字演讲还是反之。 文字语音在上面的大多数问题中都有涉及,可以在Watson网站上进行参考-

http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/speech-to-text.html

语音转文字服务将语音转换为书面文字。 这项易于使用的服务使用机器智能将语法和语言结构方面的信息与音频信号的组成知识相结合,以生成更准确的转录。 转录连续发送回客户端,并随着听到更多语音而追溯更新。 可以针对不同的语言以及特定的领域训练识别模型。

如果您查看使用旧SDK的github项目https://github.com/FarooqMulla/BluemixExample/tree/master

有一个使用实时语音输入文本api的示例,该API将音频数据包发送到bluemix并实时接收回转录的字符串。

请注意,从1/22/16开始,新的基于Swift的SDK已因此特定功能而被破坏。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM