文本到语音不起作用,因为初始化还没有结束

时间:2017-03-23 06:05:21

标签: android speech-recognition text-to-speech voice-recognition google-text-to-speech

我正在关注这个问题以使其工作

Android TTS doesn't speak

但在他给出的答案中(gameover,true),说(line,false),说(definition_string,false)

请任何人通过告诉这些条款来帮助我。

这是我的代码

public class SecondActivity extends AppCompatActivity implements OnInitListener {
    TextToSpeech t1;
   // private final int REQ_CODE_SPEECH_INPUT = 100;
    String emailid;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        emailid="Hi,say your email id";

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        t1=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                if(status != TextToSpeech.ERROR) {
                    t1.setLanguage(Locale.US);

                }
            }
        });

        Toast.makeText(getApplicationContext(), emailid,Toast.LENGTH_SHORT).show();
        t1.speak(emailid, TextToSpeech.QUEUE_FLUSH, null);



    }

    public void onPause(){
        if(t1 !=null){
            t1.stop();
            t1.shutdown();
        }
        super.onPause();
    }
  }

1 个答案:

答案 0 :(得分:0)

试试这个,看它是否有效:

<h1>IMPORT</h1>
<div class = "well">
<p>

<%= form_tag import_reports_path do %>
    <%= file_field_tag :file%>
   <br>
  <%= submit_tag "Import",class: "btn btn-primary" %>
<% end %>
</p>
</div>