zoukankan      html  css  js  c++  java
  • Android播放功能的实现

    Android播放语言功能的实现

      需要用到的类文件TextToSpeech,此类可以实现播放语言的功能

      支持播放的语言1、英语 2、法语 3、德语 4、意语 5、西班牙语

      1、实例化此类,添加上下文对象并且提供OnInitListener接口

      TextToSpeech tts = new TextToSpeech(MainActivity.this,

      new OnInitListener() {

      @Override
      public void onInit(int status) {//当数据载入成功后启动此方法,初始化参数
      if (status == tts.SUCCESS) {//如果返回值为true
      Toast.makeText(MainActivity.this, "传输成功", 0).show();
      int result = tts.setLanguage(Locale.US);//设置语言为英语
      int result2 = tts.setLanguage(Locale.CHINESE);//中文不支持,所以这一句话设置不设置无所谓
      }
      }
        });

    2、使用句柄值tts

      tts.speak("this is an apple",TextToSpeech.QUEUE_FLUSH, null);//朗读this is an apple这段话

        三个参数

            //text   需要朗读的语言

            //queueMode 队列模式

            //params 可以置空

  • 相关阅读:
    makefile
    xcode
    centos
    debug
    服务器开发
    socket
    xcode
    调用cpp库更基本
    nodejs cpp动态库
    html5图片裁剪法--
  • 原文地址:https://www.cnblogs.com/MainActivity/p/6013418.html
Copyright © 2011-2022 走看看