centos 7 安装Ekho,文本转语音_嗼淰_新浪博客

1.ekho 介绍:

http://www.eguidedog.net/cn/ekho_cn.php​

​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脚本

<?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=你好

你可能感兴趣的:(php,nginx,centos,thinkphp,linux)