Texttospeech 인터페이스 작업 중입니다. 일부 처리 후에 일부 텍스트를 추가합니다. 구글 안드로이드 개발자에 따르면 당신은 TextToSpeech.QUEUE_ADD와 같이 말하는 방식으로 상수를 써야하지만 나에게 도움이되지 않는다.texttospeak.QUEUE_ADD 상수가 작동하지 않습니다.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_audio_bus);
textView = (EditText) findViewById(R.id.ipEditText);
welcomeNote = (TextView) findViewById(R.id.welcomeTextView);
text = welcomeNote.getText().toString();
speakText= text.concat(" , Please wait we are retriving information");
System.out.println("1 "+ speakText);
IP = getIntent().getExtras().getString("IP");
tts = new TextToSpeech(this, new OnInitListener() {
@Override
public void onInit(int status) {
// TODO Auto-generated method stub
if (status == TextToSpeech.SUCCESS) {
tts.setLanguage(Locale.ENGLISH);
//tts.setSpeechRate(1.1f);
speakOut(speakText);
//tts.speak(IP, TextToSpeech.QUEUE_ADD, null);
}
}
});
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://"+IP+"/checkingbusno.php");
List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("BusStopName", "thakur_complex"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
//convert response to string
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
textView.setText(result);
//initialising once again tts value
tts.speak(result, TextToSpeech.QUEUE_ADD,null);
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private void speakOut(String text) {
//String text = txtText.getText().toString();
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
@Override
public void onDestroy() {
// Don't forget to shutdown!
if (tts != null) {
tts.stop();
tts.shutdown();
}
super.onDestroy();
}
}
당신이하려는 일에 몇 가지 코드를 추가 할 수 있습니까? –
나는 그 것을 – Ashishsingh