PHPackages                             fmujie/baidu-speech-synthesis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fmujie/baidu-speech-synthesis

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fmujie/baidu-speech-synthesis
=============================

Baidu AI platform speech synthesis expansion package

1.0.4(4y ago)2541MITPHP

Since May 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/fmujie/baiduSpeechSynthesis)[ Packagist](https://packagist.org/packages/fmujie/baidu-speech-synthesis)[ RSS](/packages/fmujie-baidu-speech-synthesis/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (6)Used By (0)

现仅有百度AI平台的语音合成功能

安装
--

[](#安装)

1. 安装包文件

    ```
    $ composer require fmujie/baidu-speech-synthesis
    ```

配置
--

[](#配置)

1. 注册 `ServiceProvider`:

    ```
    Fmujie\BaiduSpeech\BaiduSpeechServiceProvider::class,
    ```
2. 创建配置文件：

    ```
    php artisan vendor:publish
    ```

    通常得需要选择`publish`哪一个服务，因为没带参数，选择编号 **\[n \]**

    ```
    [n ] Provider: Fmujie\BaiduSpeech\BaiduSpeechServiceProvider
    ```

    执行命令后会在 `config` 目录下生成本扩展配置文件：`laravel-baidu-speech.php`。
3. 在 `.env` 文件中增加如下配置：

    - `BAIDU_APP_ID`：百度`AppId`。
    - `BAIDU_API_KEY`：百度`ApiKey`。
    - `BAIDU_SECRET_KEY`：百度`SecretKey`。

使用
--

[](#使用)

1. 语音合成

    ```
    $BaiduSpeech = new Fmujie\BaiduSpeech\BaiduSpeech();
    $BaiduSpeech->combine($text, $userID, $lan, $speed, $pitch, $volume, $person);
    ```

    接口字段：

    参数类型说明可为空textString合成的文本NuserIDString用户唯一标识YlanString语言，可选值 \['zh'\]，默认为zhYspeedInteger语速，取值0-9，默认为5中语速YpitchInteger音调，取值0-9，默认为5中语调YvolumeInteger音量，取值0-15，默认为5中音量YpersonInteger发音人选择, 0为女声，1为男声，3为情感合成-度逍遥，4为情感合成-度丫丫，默认为普通女YdiskString储存盘符选择默认'public'Y接口返回字段详细见 [百度官方文档](https://cloud.baidu.com/doc/SPEECH/TTS-Online-PHP-SDK.html).

    返回的语音信息保存在storage/audios/back.mp3中

    #### 调用示例

    [](#调用示例)

    ```
