sergix44/oddcast-tts-php

PHP 接口,用于在线 Oddcast 演示 API

1.1 2020-01-08 14:46 UTC

This package is auto-updated.

Last update: 2024-09-14 03:13:28 UTC


README

一个用于与 Oddcast TTS 引擎在线演示进行交互的库。

安装

composer require sergix44/oddcast-tts-php

示例用法

所有语音都在官方 Oddcast 演示页面上列出: http://ttsdemo.com/

每个语音都对应一个命名空间,例如英文语音 Julia,位于命名空间 SergiX44/OddcastTTS/Voices/English/Julia_US.php 中,依此类推。

默认语音是 Julia(美国英语)

use SergiX44\OddcastTTS\Oddcast;

$tts = new Oddcast();
$tts->setText('Hello my friend!')

$url = $tts->getUrl(); // the url to the .mp3 file
$stream = $tts->getAudio(); // the audio file
$tts->save('path/to/file.mp3'); // save the mp3 on the filesystem

您可以在主要构造函数中轻松更改语音

use SergiX44\OddcastTTS\Oddcast;
use \SergiX44\OddcastTTS\Voices\Italian\Raffaele;

$tts = new Oddcast(Raffaele::class);
$url = $tts->setText('Hello my friend!')->getUrl();

或通过设置器

use SergiX44\OddcastTTS\Oddcast;
use \SergiX44\OddcastTTS\Voices\Italian\Raffaele;

$tts = new Oddcast();
$url = $tts->setText('Hello my friend!')
  ->setVoice(Raffaele::class)
  ->getUrl(); // you can chain all the calls together