我正在尝试在静态字符串上运行tts,但是我无法听到TTS的任何输出,这是我的代码。
public class MainActivity extends AppCompatActivity implements
CircleMenu.OnItemClickListener,GoogleApiClient.OnConnectionFailedListener,
TextToSpeech.OnInitListener{
private static final String TAG = "MainActivity";
RecyclerView recyclerView;
MaterialDialog.Builder materialDialog;
CardAdapter cardAdapter;
private GoogleApiClient mGoogleApiClient;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthStateListener;
private static int RC_SIGNIN=0;
ProgressDialog progressDialog;
FirebaseClient firebaseClient;
TextToSpeech textToSpeech;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textToSpeech=new TextToSpeech(this,this);
textToSpeech.speak("I am Supposed TO Shout",TextToSpeech.QUEUE_FLUSH,null,null);
}
@Override
protected void onPause() {
textToSpeech.stop();
textToSpeech.shutdown();
super.onPause();
}
@Override
public void onInit(int status)
{
if(status==TextToSpeech.SUCCESS){
Toast.makeText(this, "Your Device Is Not Missing TTS", Toast.LENGTH_SHORT).show();
int language=textToSpeech.setLanguage(Locale.UK);
if(language==TextToSpeech.LANG_MISSING_DATA || language==TextToSpeech.LANG_NOT_SUPPORTED)
{
}
}
else{
Toast.makeText(this, "Your Device Is Missing TTS", Toast.LENGTH_SHORT).show();
}
}
}
我不知道我在哪里错了,我在github上寻找类似的代码,它们和我在这里完全相同Credits:SurvingWithAndroid 但他们似乎在我的设备上工作