나는 사용자의 위치를 찾기 위해 백그라운드 서비스를 작성했습니다. 이제 그의 위치가 변경되면 사용자에게 음성 알림을 보내려고합니다. 위치 변경을 결정하고 간단한 푸시 알림을 보내는 코드를 작성했습니다. 이제는 음성 알림 또는 음성 알림 코드 작성 방법에 대해 도움을 줄 수 있거나 음성 알림을 전송하는 제 3 자 라이브러리가 있습니다. 사용자. 감사합니다. 음성 API를 여기 see reference hereandroid는 사용자에게 음성 알림을 전송합니다.
1
A
답변
2
예 마지막으로 나는 매우 쉬운 방법으로 완벽한 솔루션을 얻었습니다.
private TextToSpeech myTTS; // Define the TTS objecy
private int MY_DATA_CHECK_CODE = 0;
//write the following code in oncreate method or whereever you want to use this
{
myTTS = new TextToSpeech(this, this);
Intent checkTTSIntent = new Intent();
checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE);
speakWords("Pass the String here");
}
private void speakWords(String speech) {
//speak straight away
//myTTS.setLanguage(Locale.US);
System.out.println(speech + " TTSTTTS");
myTTS.speak(speech, TextToSpeech.LANG_COUNTRY_AVAILABLE, null);
}
public void onInit(int status) {
// TODO Auto-generated method stub
if (status == TextToSpeech.SUCCESS) {
if(myTTS.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE)
myTTS.setLanguage(Locale.US);
} else if (status == TextToSpeech.ERROR) {
Toast.makeText(getApplicationContext(), "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show();
}
}
1
사용 안드로이드 텍스트는 그 부분을 여기에 붙여해야 할 수 있습니다 예를 들어 link이다. (notificationManager.notify(0, notification);
가 호출) 알림 방법에
private TextToSpeech myTTS;
Intent checkTTSIntent = new Intent();
checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE);
myTTS.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
speakWords(words); //call this function with the string you want as voice
//speak the user text
private void speakWords(String speech) {
//speak straight away
myTTS.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
}
//act on result of TTS data check
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == MY_DATA_CHECK_CODE) {
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
//the user has the necessary data - create the TTS
myTTS = new TextToSpeech(this, this);
}
else {
//no data - install it now
Intent installTTSIntent = new Intent();
installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installTTSIntent);
}
}
}
//setup TTS and don't forget to implement OnInitListener interface to use this method
public void onInit(int initStatus) {
//check for successful instantiation
if (initStatus == TextToSpeech.SUCCESS) {
if(myTTS.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE)
myTTS.setLanguage(Locale.US);
}
else if (initStatus == TextToSpeech.ERROR) {
Toast.makeText(this, "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show();
}
}
2
에 감사
1
, 다음을 추가하면 알림을 밀어 때마다
try {
Uri ring_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), ring_uri);
r.play();
} catch (Exception e) {
// Error playing sound
}
이 알림 소리가납니다.
관련 문제
- 1. Android는 ACTION_MEDIA_BUTTON 의도를 에뮬레이트/전송합니다.
- 2. 자바 메일 API를 사용하여 새 사용자에게 전자 메일 알림을 전송합니다.
- 3. 전화 사이에 푸시 알림을 전송합니다.
- 4. 서버가 Android Phone에 알림을 전송합니다.
- 5. Apple 푸시 알림 서비스가 반복 알림을 전송합니다.
- 6. 레일에있는 사용자에게 알림을 보내시겠습니까?
- 7. Android는 두 소리를 음성 일치로 비교합니다.
- 8. 사용자에게 알림을 보내는 방법은 무엇입니까?
- 9. 각 세션 사용자에게 BroadCast Admin 메시지를 전송합니다.
- 10. PHP를 사용하여 사용자에게 알림을 보내는 방법은 무엇입니까?
- 11. 사용자에게 안드로이드 알림을 취소 할 수 있습니까?
- 12. PAR :: Packer : 사용자에게 알림을 표시하는 방법은 무엇입니까?
- 13. Google App Engine - 사용자에게 알림을 보내려면 어떻게해야합니까?
- 14. IOS 푸시 알림을 특정 사용자에게 보내시겠습니까?
- 15. Facebook 사용자에게 알림을 보낼 수있는 기능은 무엇입니까?
- 16. 사용자에게 앱 업데이트 알림을 제공하는 방법
- 17. 연결된 모든 사용자에게 알림을 보내는 방법은 무엇입니까?
- 18. 레일에서 다른 사용자에게 알림을 보내는 방법
- 19. TFS [요청자] 사용자에게 전자 메일 알림을 작성하십시오.
- 20. 다른 사용자에게 알림을 보내는 방법은 현재 온라인 상태입니까?
- 21. Adhoc 또는 푸시 알림을 사용하여 Ipad/Ipod/컴퓨터간에 데이터를 전송합니다.
- 22. GCD Dispatch - 다른 메소드가 호출 될 때 알림을 전송합니다.
- 23. Android는 상태 표시 줄을 좋아합니까?
- 24. Android 음성 텍스트 음성 음성
- 25. android는 탭 스위치에서 작업을 수행합니다.
- 26. Android는 Bluetooth를 통해 응용 프로그램에서 PC/프린터/스캐너/다른 장치로 파일/데이터를 전송합니다.
- 27. 내 응용 프로그램을 사용하는 모든 사용자에게 대량 알림을 보내는 방법
- 28. 웹 사이트에서 사용자에게 SMS 알림을 구성하는 방법은 무엇입니까?
- 29. iPhone에 "자동"푸시 알림을 보낼 수 있습니까 (사용자에게 경고하지 않음)?
- 30. 실시간 알림을 추적하여 사용자에게 보낼 수있는 가장 좋은 방법은 무엇입니까?
안녕하세요, 저는이 소리를 사용자 정의 할 수 있습니까, 지금은 특정 문자열을 말하고 싶습니다. 최대한 빨리 회신 해주십시오 –
재생하려는 각 음성의 음성 파일이있는 경우이 파일을 사용할 수는 있지만 문제가 아닌 것으로 생각합니다. TextToSpeech 클래스를 사용해야합니다. –
Ok, 도움 주셔서 감사합니다. –