我有一个使用SAPI进行TTS的Web应用程序.我在默认安装了MS Sam的Windows Server 2003上运行它.
据我所知,有很多第三方公司都在销售声音.对于商业应用,哪些公司提供的许可证不收取大量费用?他们有API可以轻松地与ASP.NET应用程序集成吗?
我真的想为应用程序添加更多声音.
编辑:再说一遍?谢谢
有谁知道是否有适用于Windows,Mac和Linux的文本到语音的Python库?
TextToSpeech构造函数看起来像是由Activity"拥有".我正在制作一个包含多个不同活动的应用程序,我不想为每个活动初始化一个新的TextToSpeech实例 - 我希望即使活动正在改变,语音也能顺利进行.
我的想法是让所有活动访问一个静态TextToSpeech对象,由第一个对象初始化.
我正在玩Android的TTS功能,TextToSpeech类有这个方法来设置一个侦听器,一旦TextToSpeech完成播放就会收到通知:
public int setOnUtteranceCompletedListener(TextToSpeech.OnUtteranceCompletedListener listener)
Run Code Online (Sandbox Code Playgroud)
但OnUtteranceCompletedListener定义为public abstract class.由于我MainActivity已经扩展了Activity,它也无法扩展OnUtteranceCompletedListener.我可以使用旧的方法OnUtteranceCompletedListener,但不推荐使用:
public int setOnUtteranceCompletedListener (TextToSpeech.OnUtteranceCompletedListener listener)`
Run Code Online (Sandbox Code Playgroud)
为什么OnUtteranceCompletedListener没有定义为public static interface?我正在考虑编写自己的UtteranceProgressListenerImpl,然后只调用MainActivitys onDone方法.这是正确的方式还是有更好/更清洁的选择?
private class UtteranceProgressListenerImpl extends UtteranceProgressListener {
private MainActivity mainActivity;
UtteranceProgressListenerImpl(MainActivity mA) {
mainActivity = mA;
}
@Override
public void onDone(String utteranceId) {
mainActivity.onDone(utteranceId);
}
@Override
public void onError(String utteranceId) { /* empty */ }
@Override
public void onStart(String utteranceId) { /* empty */ } …Run Code Online (Sandbox Code Playgroud) 我已经按照几个教程,但我遇到了同样的问题.首先,这是我的简单代码:
import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.util.Log;
public class AchievementsActivity extends Activity implements OnInitListener {
TextToSpeech reader;
Locale canada;
boolean readerInit = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
canada = Locale.ENGLISH;
reader = new TextToSpeech(this, this);
//speak();
// while (reader.isSpeaking()) {} //waiting for reader to finish speaking
}
@Override
public void onStart() {
super.onStart();
//speak();
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) …Run Code Online (Sandbox Code Playgroud) 我想用我自己的声音作为Android上的TTS语音,可以这样做吗?
我正在使用android studio v0.1并针对4.2 jellybean进行编译,尝试了音高和速度但没有任何作用..
我创建了一个示例示例,该示例使用仅在Chrome上运行的JavaScript使用HTML5进行文本语音转换,但是当我尝试在其他浏览器(即IE,Mozilla,Safari)上运行该示例时,则不会出现任何问题。我应该怎么做才能在所有浏览器上运行“文本转语音”演示代码。
<code>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>
<script>
$(document).ready(function () {
$("#startBtn").on('click', function (e) {
debugger;
var u1 = new SpeechSynthesisUtterance('Hello Word..');
u1.lang = 'en-US';
u1.pitch = 1;
u1.rate = 1;
//u1.voice = voices[10];
u1.voiceURI = 'native';
u1.volume = 1;
speechSynthesis.speak(u1);
});
});
</script>
<title> </title>
</head>
<body>
<input type="button" id="startBtn" value="Hello Word.." />
</body>
</html>
</code>
Run Code Online (Sandbox Code Playgroud) 使用的代码:
public class TexttoSpeechActivity extends Activity implements OnInitListener {
private TextToSpeech tts;
private Button btnSpeak;
private EditText txtText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tts = new TextToSpeech(this, this);
btnSpeak = (Button) findViewById(R.id.btnSpeak);
txtText = (EditText) findViewById(R.id.txtText);
btnSpeak.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
speakOut();
}
});
}
@Override
public void onDestroy() {
// Don't forget to shutdown!
if (tts != null) {
tts.stop();
tts.shutdown();
}
super.onDestroy();
}
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) …Run Code Online (Sandbox Code Playgroud) 我想将NAudio和SpeechSynthesizer一起使用,但是如果不首先将.wav文件写入磁盘,我就无法工作.
我无法弄清楚为什么,我尝试了RAW wav数据和带标题的wav,请参阅以下示例.
我有以下示例:
示例1 - 这可以工作,但保存.wav文件
using (var synth = new SpeechSynthesizer())
{
synth.SetOutputToWaveFile(@".\Test.wav");
synth.Speak("This is sample text-to-speech output.");
synth.SetOutputToNull();
var reader = new WaveFileReader(@".\Test.wav");
var waveOut = new WaveOut();
waveOut.Init(reader);
waveOut.Play();
}
Run Code Online (Sandbox Code Playgroud)
示例2 - 这也有效,但仍然使用文件
using (var synth = new SpeechSynthesizer())
using (var stream = new MemoryStream())
{
synth.SetOutputToWaveStream(stream);
synth.Speak("This is sample text-to-speech output.");
using (var fileStream = File.Create(@".\Test.wav"))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
}
var reader = new WaveFileReader(@".\Test.wav");
var waveOut = new WaveOut();
waveOut.Init(reader);
waveOut.Play();
}
Run Code Online (Sandbox Code Playgroud)
示例3 …
我有一个带有两个ImageButtons(播放,停止)的FrameLayout .默认情况下
播放按钮是VISIBLE,停止按钮是GONE
单击" 播放"将启动读取文本的TTS引擎.在完成阅读文本时,我想设置可见性
玩GONE,停止VISIBLE
我应该使用UtteranceProgressListener来达到目的吗?如果不,