eSpeak是一套OPEN SOURCE的TTS程式,支援各國語言。只是聲音有點奇怪很呆版。eSpeak有提供CLI操作。(CLI就是command-line interface)
eSpeak官方網站http://espeak.sourceforge.net/
eSpeak 的 Additional Data 安裝後zh_listx 中文聲音會改變,解壓縮後放到eSpeak資料夾裡的dictsource下。再命令提示字元打指令espeak --compile=zh即可安裝。Windows 的 CMD 預設編碼非UTF-8,必須用讀取檔案方式才會正常。.
CLI 使用範例:
在CLI下打espeak "Hello world"
espeak 加上要發音的字串
espeak -v en -f -s100 textfile.txt
-v en是聲音的語言
-f textfile.txt是讀取檔案內容轉成聲音
-s 每分鐘幾個字,預設 170
espeak -w test.wav "hello"
-w test.wav "hello"把hello聲音轉存成wav檔案
espeak -a120 -g20 -p 60 "Hello world"
-a120調整音量預設 100
-g20字與字間的間隔,預設 10mS
-p60音調高低,調高會偏女聲,調低會偏男聲, 預設 50
聲音參數The available variants are:male: +m1 +m2 +m3 +m4 +m5female: +f1 +f2 +f3 +f4other effects: +croak +whisper
JAVA透過CMD呼叫是讓程式使用的最簡單的方式,之後再介紹透過API呼叫的方法。
package cli;
import java.io.*;
public class CLI {
public static void main(String[] args) {
Runtime WCLI=Runtime.getRuntime();
Process p= null;
try {
p = WCLI.exec( "C:\\Program Files (x86)\\eSpeak\\command_line\\espeak -vzh+f2 -w abc.wav -f abc.txt");
InputStream in =p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String str = null;
while((str=br.readLine())!= null)
System.out.println(str);
br.close();
} catch (Exception e) {
System.out.println( "Error exec notepad ");
}
}
}
JAVA透過CMD呼叫是讓程式使用的最簡單的方式,之後再介紹透過API呼叫的方法。
package cli;
import java.io.*;
public class CLI {
public static void main(String[] args) {
Runtime WCLI=Runtime.getRuntime();
Process p= null;
try {
p = WCLI.exec( "C:\\Program Files (x86)\\eSpeak\\command_line\\espeak -vzh+f2 -w abc.wav -f abc.txt");
InputStream in =p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String str = null;
while((str=br.readLine())!= null)
System.out.println(str);
br.close();
} catch (Exception e) {
System.out.println( "Error exec notepad ");
}
}
}
全站熱搜
留言列表