我想知道如何在我的.NET项目中使用Google Text-to-Speech API.我想我需要调用一个URL来使用Web服务,但对我来说这个想法并不清楚.有人可以帮忙吗?
我需要在JavaScript中使用Google文本转语音.
想法是使用Web服务:
http://translate.google.com/translate_tts?tl=en&q=This%20is%20just%20a%20test
并在certian动作上播放,例如点击按钮.
但似乎它不像加载普通的wav/mp3文件:
<audio id="audiotag1" src="audio/example.wav" preload="auto"></audio>
<script type="text/javascript">
function play() {
document.getElementById('audiotag1').play();
}
</script>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我在Google Chrome v34.0.1847.131上使用语音合成API.从v33开始,该API在Chrome中实施.
除了分配回调时,文本到语音大部分都有效onend.例如,以下代码:
var message = window.SpeechSynthesisUtterance("Hello world!");
message.onend = function(event) {
console.log('Finished in ' + event.elapsedTime + ' seconds.');
};
window.speechSynthesis.speak(message);
Run Code Online (Sandbox Code Playgroud)
有时会打电话onend,有时不打电话.时机似乎完全没有了.当它被调用时,打印elapsedTime总是像一些时代一样1399237888.
javascript google-chrome text-to-speech speech-synthesis google-text-to-speech
Google实施了验证码以阻止用户访问TTS翻译API https://translate.google.com/translate_tts?ie=UTF-8&q=test&tl=zh-TW.我在我的移动应用程序中使用它.现在,它没有返回任何东西.我如何绕过验证码?
我尝试在手机中触发特定事件时播放TextToSpeech对象.
但是,我遇到了大多数手机上安装的默认Google TTS引擎的问题.截至目前,我正在初始化TextToSpeech对象后立即播放一些文本,并在语音完成后立即关闭资源,如下面的代码所示:
public class VoiceGenerator {
private Context context = null;
private static TextToSpeech voice = null;
public VoiceGenerator(Context context)
{
this.context = context;
}
public void voiceInit(String text)
{
try {
if (voice == null) {
new Thread(new Runnable() {
@Override
public void run() {
voice = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
@Override
public void onInit(final int status) {
try {
if (status != TextToSpeech.ERROR) {
voice.setLanguage(Locale.US);
Log.d("VoiceTTS", "TTS being initialized");
HashMap p = new HashMap<String, …Run Code Online (Sandbox Code Playgroud) 我是第一次学习android开发,我的目标是创建一个简单的Hello World应用程序,它接收一些文本,并大声读出它们.
我的代码基于我找到的一个例子,这是我的代码:
class MainFeeds : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main_feeds)
card.setOnClickListener{
Toast.makeText(this, "Hello", Toast.LENGTH_LONG).show()
TTS(this, "Hello this is leo")
}
}
}
class TTS(private val activity: Activity,
private val message: String) : TextToSpeech.OnInitListener {
private val tts: TextToSpeech = TextToSpeech(activity, this, "com.google.android.tts")
override fun onInit(i: Int) {
if (i == TextToSpeech.SUCCESS) {
val localeUS = Locale.US
val result: Int
result = tts.setLanguage(localeUS)
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Toast.makeText(activity, "This Language is …Run Code Online (Sandbox Code Playgroud) android voice text-to-speech speech-synthesis google-text-to-speech
我想通过 Google Cloud text-to-speech API使用SSML 标记来请求音频流中这些标记的时间。这些时间戳是必要的,以便为用户提供效果提示、单词/部分突出显示和反馈。
我发现这个问题是相关的,尽管这个问题是指每个单词的时间戳而不是 SSML<mark>标签。
以下 API 请求返回 OK,但显示缺少请求的标记数据。这是使用Cloud Text-to-Speech API v1.
{
"voice": {
"languageCode": "en-US"
},
"input": {
"ssml": "<speak>First, <mark name=\"a\"/> second, <mark name=\"b\"/> third.</speak>"
},
"audioConfig": {
"audioEncoding": "mp3"
}
}
Run Code Online (Sandbox Code Playgroud)
回复:
{
"audioContent":"//NExAAAAANIAAAAABcFAThYGJqMWA..."
}
Run Code Online (Sandbox Code Playgroud)
它只提供没有任何上下文信息的合成音频。
是否有我忽略的 API 请求可以公开有关这些标记的信息,例如IBM Watson和Amazon Polly 的情况?
我正在尝试将单词转换为语音.
直到现在我都试过这个:
<?php
$text = "Hello this is a test for voice api of google";
// Name of the MP3 file generated using the MD5 hash
$file = md5($text);
// Save the MP3 file in this folder with the .mp3 extension
$file = "audio/" . $file .".mp3";
if($file) {
echo "created";
} else {
echo "not created";
}
// If the MP3 file exists, do not create a new request
if (!file_exists($file)) {
$mp3 = file_get_contents( …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Android Text To Speech讲出大量文本.我使用默认的Google语音引擎.以下是我的代码.
public class Talk extends Activity implements TextToSpeech.OnInitListener {
private ImageView playBtn;
private EditText textField;
private TextToSpeech tts;
private boolean isSpeaking = false;
private String finalText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_talk);
//Intialize the instance variables
playBtn = (ImageView)findViewById(R.id.playBtn);
textField = (EditText)findViewById(R.id.textField);
//Resister the listeners
playBtn.setOnClickListener(new PlayBtnAction());
//Other things
tts = new TextToSpeech(this,this);
//Get the web page text if called from Share-Via
if (Intent.ACTION_SEND.equals(getIntent().getAction()))
{
new GetWebText().execute("");
}
}
//This class will execute the text …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 App Engine flex 环境中实现 Google 的文本转语音 API,但出现此错误:
“PHP 消息:PHP 致命错误:未捕获错误:调用 /app/web/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:941 中未定义的函数 Google\Protobuf\Internal\bccomp()”
一旦我通过在我的composer.json中要求BCmath()解决了问题
{
"require": {
"ext-bcmath": "*",
"google/cloud-text-to-speech": "^1.0",
"google/gax": "^1.3",
"grpc/grpc": "^1.4",
"google/auth": "^1.8",
"phpseclib/phpseclib": "^2.0",
"google/protobuf": "^3.11"
}
}
Run Code Online (Sandbox Code Playgroud)
然后重新安装 /vendor 后我无法摆脱错误消息。我尝试通过运行来安装 BCmath 扩展
sudo apt install php7.2-bcmath
Run Code Online (Sandbox Code Playgroud)
但它说扩展已经安装。我也运行这个 php -i | grep -i bcmath 并收到此消息
/etc/php/7.2/cli/conf.d/20-bcmath.ini,bcmath BCMath 支持 => 启用 bcmath.scale => 0 => 0
bccomp() 的测试
php -r "echo bccomp('1', '2');"
Run Code Online (Sandbox Code Playgroud)
我按预期得到“-1”。看起来该功能有效。
我什至尝试在 php.ini 中启用 BCmath 扩展
extension=bcmath.so
Run Code Online (Sandbox Code Playgroud)
我将 .ini 文件放在与 /vendor 和 …
php google-app-engine bcmath google-text-to-speech composer-php