thuanvp012van / gtts
此包最新版本(v1.2.0)没有提供许可证信息。
Google Text-to-Speech for php
v1.2.0
2023-06-20 01:14 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: >=7.5
- symfony/console: >=6.1
This package is auto-updated.
Last update: 2024-09-20 03:57:42 UTC
README
安装
composer require thuanvp012van/gtts
用法
-
与php一起使用
use Thuanvp012van\GTTS\GTTS; use Thuanvp012van\GTTS\Language; require './vendor/autoload.php'; $gtts = new GTTS('Xin chào mọi người', Language::VI); // or $gtts = (new GTTS('Xin chào mọi người'))->autoDetection(true); $gtts->save('helloworld.mp3');
-
与命令行一起使用
php ./vendor/bin/gtts languages # Show all languagesphp ./vendor/bin/gtts save --file=helloworld.mp3 --language=vi 'Xin chào mọi người' # Convert text to speech.
或者
php ./vendor/bin/gtts save --file=helloworld.mp3 --auto-detection 'Xin chào mọi người' # Automatic language detection.
方法
text(string $text): 设置文本。getText(): 获取文本。lang(\Thuanvp012van\GTTS\Language $lang): 设置语言。getLang(): 获取语言。autoDetection(bool $autoDetection): 设置自动检测。isAutoDetection(): 检查是否自动检测。topLevelDomain(string $tld): 设置顶级域名。getLevelDomain(): 获取顶级域名。slowSpeed(): 设置慢速阅读速度。normalSpeed(): 设置正常阅读速度。isSlowSpeed(): 检查是否为慢速阅读速度。isNormalSpeed(): 检查是否为正常阅读速度。save(string $fileName): 将语音保存为文件。stream(): 获取语音部分。