Text-to-speech

http://www.ispeech.org/text.to.speech

String url = "http://www.ispeech.org/p/generic/getaudio?text="+"永安里路口西"+"&voice=chchinesemale&speed=0&action=convert";
		HttpGet request = new HttpGet(url);
		try {

			HttpClient client = new DefaultHttpClient();
			client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); 
			client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000);
			HttpResponse response = client.execute(request);
			System.out.println("ispeech:"+response.getStatusLine().getStatusCode());
			if (response.getStatusLine().getStatusCode() == 200) {
			InputStream inputStream = response.getEntity().getContent();
			File file = new File(Environment.getExternalStorageDirectory()+"/libs/lizhen.mp3");
			FileOutputStream output = new FileOutputStream(file);
			byte[] buffer = new byte[1024];
			do{
				int numread = inputStream.read(buffer);
				if(numread == -1){
					break;
				}
				output.write(buffer, 0, numread);
			}while(true);
			output.flush();
			output.close();
			inputStream.close();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


阅读更多
换一批

关于asp.net应用TTS(Text-to-Speech)的问题

03-04

本人想在网站中应用微软TTS技术rn代码如下:rnusing System;rnusing System.Data;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing SpeechLib;rnrnrnnamespace TTSrnrn public partial class _Default : System.Web.UI.Pagern rn protected void Page_Load(object sender, EventArgs e)rn rn string mystr = "告警的封锁电话费肯定将恢复对今h";rn Label1.Text = mystr;rn SpeechVoiceSpeakFlags myflg = SpeechVoiceSpeakFlags.SVSFlagsAsync;rn SpVoice myvoice = new SpVoice();rn myvoice.Speak(mystr, myflg);rnrn rnrn protected void Button1_Click(object sender, EventArgs e)rn rnrn //myvoice.WaitUntilDone(1000);rn rn rnrn在调试状态下一切正常,但发布后出现rn[color=#FF0000]“/”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrn拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED)) rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.UnauthorizedAccessException: 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED)) rnrnASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 MACHINE\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。 rnrn要将 ASP.NET 访问权限授予某个文件,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。rnrn源错误: rnrnrn行 22: SpeechVoiceSpeakFlags myflg = SpeechVoiceSpeakFlags.SVSFlagsAsync;rn行 23: SpVoice myvoice = new SpVoice();rn行 24: [color=#FF0000]myvoice.Speak(mystr, myflg);[/color]行 25: rn行 26: [/color] rnrn请问该如何解决?rn

没有更多推荐了,返回首页