zoukankan      html  css  js  c++  java
  • 讯飞语音识别的录音文件wav存储

    void start(){
    //在小米5的手机上直接向getExternalStorageDirectory写文件会出现文件管理器找不文件的情况,
    这时候就要提前生成这个文件夹,防止存储wav文件失败。

    mkdir();   String path
    = Environment.getExternalStorageDirectory().getAbsolutePath() + "/0/" + wavFileCount + ".wav";   mIat.setParameter(SpeechConstant.ASR_AUDIO_PATH, path);   //开始识别,并设置监听器   mIat.startListening(mRecognizerListener); } private void mkdir() { try {   String rootPath = Environment.getExternalStorageDirectory().getAbsolutePath();   File dirFile = new File(rootPath);   if (!dirFile.exists()) {     dirFile.mkdir();   }   String dir0Path = rootPath + "/0/";   File dir = new File(dir0Path);   if (!dir.exists()) {     dir.mkdir();   } // String wavPath = rootPath + "/0/test.wav"; // File file = new File(wavPath); // if (!file.exists()) { // FileOutputStream fos = new FileOutputStream(wavPath); // fos.write("123".getBytes()); // fos.flush(); // fos.close(); // }   } catch (Exception e) {     e.printStackTrace();   } }
  • 相关阅读:
    Linux 查看端口占用情况
    Linux 的 ls 和 ll 的使用方法:
    awk文本分析
    【Linux】/etc/passwd文件中字段解释
    vue学习笔记(八)---源码学习
    uniapp学习笔记(更新中)
    微信小程序学习
    哈希表的原理
    容器通常具备一些固定的方法
    字符串的方法
  • 原文地址:https://www.cnblogs.com/Oldz/p/13355803.html
Copyright © 2011-2022 走看看