[分享] 简单脚本调用 google 在线 tts

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
hecha
帖子: 364
注册时间: 2007-09-23 13:36

[分享] 简单脚本调用 google 在线 tts

#1

帖子 hecha » 2011-03-27 0:04

使用 google 翻译时,发现 google 的中文 tts 挺不错的
查了一下

代码: 全选

http://translate.google.com/translate_tts?tl=zh&q=hello
返回一个 hello 读音的 mp3 文件

代码: 全选

#!/bin/sh
while read line
do
	wget -q -UMozilla/5.0 "http://translate.google.com/translate_tts?tl=$1&q=$line" -O-
done | madplay -Q -
用法

代码: 全选

$ date +%c | ./speek zh 
用 madplay 播放 mp3 文件,需要自己安装
脚本是一句句地读的,经过测试,太长的句子 google 不会返回 mp3 文件(大概 256 字节),所以需要将文件先处理一下,分成较短的行
下载和朗读是同步的,我试了几句话,流畅度还可以,质量也还行
口口!口口被口口了!
回复