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();
		}


阅读更多
想对作者说点什么? 我来说一句

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