google tts 文本转语音 python 库:
https://github.com/hungtruong/Google-Translate-TTS
1 2 3 4 5 6 | $ python GoogleTTS.py -l zh-CN -f abc中文朗读测试.txt #生成out.mp3 sudo apt-get install mplayer2 mplayer2 out.mp3 |
最简单的办法,直接执行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | gamexg@ubuntu:~/yysb$ mplayer "http://translate.google.cn/translate_tts?ie=UTF-8&q=abc中文 朗读测试&tl=zh-CN" MPlayer2 UNKNOWN (C) 2000-2012 MPlayer Team mplayer: could not connect to socket mplayer: No such file or directory Failed to open LIRC support. You will not be able to use your remote control. Playing http://translate.google.cn/translate_tts?ie=UTF-8&q=abc中文朗读测试&tl=zh-CN. Resolving translate.google.cn for AF_INET6... Connecting to server translate.google.cn[2404:6800:4008:c00::a0]: 80... Failed to connect to server with AF_INET6 Resolving translate.google.cn for AF_INET... Connecting to server translate.google.cn[203.208.41.148]: 80... Cache size set to 320 KBytes Cache fill: 3.76% (12330 bytes) Detected file format: Audio only ========================================================================== Requested audio codec family [mpg123] (afm=mpg123) not available. Enable it at compilation. Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 22050 Hz, 1 ch, floatle, 32.0 kbit/4.54% (ratio: 4000->88200) Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio) ========================================================================== AO: [pulse] 22050Hz 1ch floatle (4 bytes per sample) Video: no video Starting playback... A: 3.0 (03.0) of 3.0 (03.0) 0.1% 0% Exiting... (End of file) gamexg@ubuntu:~/yysb$ |