[开箱即用] 一款满足多种平台使用「文字转语音」的组件

Easy Tts For Laravel#

一款满足你的多种 TTS 平台调用组件

License

特点#

  1. 支持目前市面多家服务商
  2. 一套写法兼容所有平台
  3. 支持实时流式返回(短文本)创建异步任务(长文本)
  4. 支持多种参数设置
  5. 更多等你去发现与改进…

平台支持#

环境需求#

  • PHP >= 7.4

安装#

$ composer require raison/easy-tts-laravel```

## 各平台配置说明

### 在 config/app.php 文件中设置服务提供者和别名。

```php
'providers' => [
 .... EasyTts\Providers\LaravelServiceProvider::class, ....],

请使用下面这条命令来发布配置文件

 php artisan vendor:publish --provider="EasyTts\Providers\LaravelServiceProvider"

科大讯飞#

'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);

License#

MIT

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 12

找不到这个包文件

file

2年前 评论
raison (楼主) 2年前
raison (楼主) 2年前

有语音转文字的吗

2年前 评论

安装报错

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires raison/easy-tts-laravel * -> satisfiable by raison/easy-tts-laravel[dev-main, 1.0.0, 9999999-dev].
    - raison/easy-tts-laravel[dev-main, 1.0.0] require illuminate/support ^5.2|^6|^7|^8 -> found illuminate/support[v5.2.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.
2年前 评论
小李世界 2年前

file

2年前 评论
raison (楼主) 2年前
shebaoting (作者) 2年前
raison (楼主) 2年前
shebaoting (作者) 2年前