PHP code example of raison / easy-tts-laravel
1. Go to this page and download the library: Download raison/easy-tts-laravel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
raison / easy-tts-laravel example snippets
'providers' => [
....
EasyTts\Providers\LaravelServiceProvider::class,
....
],
'xunfei' => [
'driver' => 'xunfei',
'appid' => '',
'secret_id' => '',
'secret_key' => '',
],
'tencent' => [
'driver' => 'tencent',
'appid' => '',
'secret_id' => '',
'secret_key' => '',
],
'aliyun' => [
'driver' => 'aliyun',
'appid' => '',
'secret_id' => '',
'secret_key' => '',
],
'baidu' => [
'driver' => 'baidu',
'appid' => '',
'secret_id' => '',
'secret_key' => '',
],
use EasyTts\TtsManager;
(new TtsManager())->client()->textToSpeechStream('PHP是全世界最好的语言');
use EasyTts\TtsManager;
$text = "php是全世界最好的语言";
$config = [
'speed' => 50,
'volume' => 50,
'vcn' => "xiaoyan",
];
return (new TtsManager())->client('xunfei')->setRequestConfig($config)->textToSpeechStream($text);
use EasyTts\TtsManager;
$text = "php是全世界最好的语言";
$config = [
'Speed' => 0,
'Volume' => 0,
'VoiceType' => 10510000,
];
return (new TtsManager())->client('tencent')->setRequestConfig($config)->textToSpeechStream($text);
use EasyTts\TtsManager;
$text = "php是全世界最好的语言";
$config = [
'Speed' => 0,
'Volume' => 0,
'VoiceType' => 10510000,
];
// 创建异步任务
$task_id = (new TtsManager())->client('tencent')->setRequestConfig($config)->createTask($text);
// 通过任务id获取结果
$res = (new TtsManager())->client('tencent')->fetchTaskResult($task_id);
use EasyTts\TtsManager;
$text = "php是全世界最好的语言";
$config = [
'speech_rate' => 200,
'voice' => 70,
'voice' => "zhitian_emo",
];
return (new TtsManager())->client('aliyun')->setRequestConfig($config)->textToSpeechStream($text);
use EasyTts\TtsManager;
$text = "php是全世界最好的语言";
$config = [
'speech_rate' => 200,
'voice' => 70,
'voice' => "zhitian_emo",
];
// 创建异步任务
$task_id = (new TtsManager())->client('aliyun')->setRequestConfig($config)->createTask($text);
// 通过任务id获取结果
$res = (new TtsManager())->client('aliyun')->fetchTaskResult($task_id);
use EasyTts\TtsManager;
$text = "php是全世界最好的语言";
$config = [
'spd' => 10,
'vol' => 10,
'per' => 3,
];
return (new TtsManager())->client('baidu')->setRequestConfig($config)->textToSpeechStream($text);
use EasyTts\TtsManager;
$text = "php是全世界最好的语言";
$config = [
'speed' => 10,
'volume' => 10,
'voice' => 3,
];
// 创建异步任务
$task_id = (new TtsManager())->client('baidu')->setRequestConfig($config)->createTask($text);
// 通过任务id获取结果
$res = (new TtsManager())->client('baidu')->fetchTaskResult($task_id);
shell
php artisan vendor:publish --provider="EasyTts\Providers\LaravelServiceProvider"