如何节省TTS输出在Android上的音频文件? [英] How can I save TTS output in an audio file on android?

查看:374
本文介绍了如何节省TTS输出在Android上的音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一篇文章在这里。我是新的Andr​​oid的编程。我想创建一个应用程序,我可以将文本到语音的输出保存到一个音频文件到我的数据库。我听说过的 synthesizeToFile()的,但它不是。

this is my first post here. I'm new in Android Programming. I want to create an app where I can save the output of the text to speech into an audio file to my database. I've heard about synthesizeToFile() but It's not it.

推荐答案

使用这种code,并从资产文件夹中的MP3文件的接取和尝试这个code。

Use this code and get the mp3 file acess from the assets folder and try this code.

mMediaPlayer = new MediaPlayer();
mMediaPlayer = MediaPlayer.create(this,R.raw.button);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.start();
mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {                   
    @Override
    public void onCompletion(MediaPlayer mp) {
        mMediaPlayer.stop();
    }
});

这篇关于如何节省TTS输出在Android上的音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆