当前位置: 首页 > 工具软件 > Ekho > 使用案例 >

centos ekho php,centos 7 安装Ekho,文本转语音

孟谭三
2023-12-01

1.ekho 介绍:

​2.安装以及依赖包安装

​2.1 依赖包安装

yum install -y ncurses-devel libsndfile-devel espeak-devel pulseaudio-libs-devel

​2.2 ekho 安装

tar xJvf ekho-xxx.tar.xz

cd ekho-xxx

./configure

make && make

install​

​3.

测试

ekho 你好 -o 1.mp3 ​

4.将文字转为语音并且网页播放PHP脚本

$text = $_GET['text'];

$volume = $pitch = $speed = 0;

$voice  = 'Mandarin';

if (isset($_GET['volumeDelta'])) {

if($_GET['volumeDelta'] >= -100

&& $_GET['volumeDelta']

<=100 ){

$volume = $_GET['volumeDelta'];

}

}

if (isset($_GET['pitchDelta'])) {

if($_GET['pitchDelta'] >= -100

&& $_GET['pitchDelta']

<=100 ){

$pitch = $_GET['pitchDelta'];

}

}

if (isset($_GET['speedDelta'])) {

if($_GET['speedDelta'] >= -50

&& $_GET['speedDelta']

<=100 ){

$speed = $_GET['speedDelta'];

}

}

if (isset($_GET['voice'])) {

if($_GET['voice'] >= -100

&& $_GET['voice']

<=100 ){

$voice = $_GET['voice'];

}

}

$filename = md5($text) . '.mp3';

$filepath = $base_dir . '/v' . $voice . 's' . $speed . 'p'

. $pitch .

'a' . $volume . 't'

. $filename;

$text = escapeshellarg($text);

if (!file_exists($filepath)) {

$cmd = "ekho -s $speed -p $pitch -a $volume -v $voice

$text -o $filepath";

//$cmd = "ekho $text -o $filepath";

//print_r($cmd);exit;

exec($cmd);

}

header('Content-Type: ');

header('Content-Length: ' .

filesize($filepath));

readfile($filepath);

5​. 页面请求

​t.php?voice=Mandarin&speedDelta=0&pitchDelta=0&volumeDelta=0&text=你好

 类似资料: