This article mainly introduces PHP online speech synthesis, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
Online speech synthesis PHP SDK
http://yuyin.baidu.com/docs/tts/194
PHP SDK Document
Introduction
Hi, welcome to Baidu Speech synthesis services.
This document is mainly aimed at PHP developers and describes the relevant technical content of Baidu speech synthesis interface service. If you have any questions about the content of the document, you can contact us through the following methods:
Submit a work order in the Baidu Cloud Console. Please select Artificial Intelligence for the type of inquiry. Service;
JoinDeveloper QQ group:464413749
##Interface capability
Interface name
Brief description of interface capability
##Speech synthesis
Translate the computer itself A technology that converts generated or externally input text information into understandable and fluent spoken output.
Notes
Currently, the functions of this SDK are the same as the REST API, and you need to connect to the Internet to call the http interface. The REST API only supports audio synthesis of up to 512 words (1024 bytes), and the synthesized file format is mp3.
No other extra features.
If you need to use other functions such as offline synthesis, please use the Android or iOS synthesis SDK Please strictly follow the parameters described in the document for development. Please pay attention to the following issues:
The length of the synthetic text must be less than 1024 bytes. If the length of the text is longer, multiple requests can be used. Don't exceed the text length limit.
Speech synthesis rest api initially applies for a default request quota of 200,000 times/day. If the default quota cannot meet the demand, please apply to increase the quota.
In the required fields, fill them in strictly according to the content in the document description.
The steps to develop using PHP SDK are as follows :
1. Download the php SDK compressed package from the official website. 2. After decompressing the downloaded
aip-php-sdk-version.zip, copy AipSpeech.php and lib/* to the project folder.
3.Introduce AipSpeech.phpNew AipSpeechAipSpeech is a PHP SDK client for speech synthesis, which provides a series of interactive methods for developers who use speech synthesis . Refer to the following code to create a new AipSpeech:
require_once 'AipSpeech.php';
// 你的 APPID AK SK
const APP_ID = '你的 App ID';
const API_KEY = '你的 Api Key';
const SECRET_KEY = '你的 Secret Key';
$client = new AipSpeech(APP_ID, API_KEY, SECRET_KEY);
Copy after login
In the above code, the constant
APP_ID is in the Baidu Cloud Console Creation, the constants API_KEY and SECRET_KEY are assigned to the user by the system after the application is created. They are both strings used to identify the user and perform signature verification for access. They can be used in AI Check it in Application List in the service console.
Configuring AipSpeechIf the user needs to configure the network request parameters of AipSpeech (generally no configuration is required), the interface can be called to set the parameters after constructing AipSpeech. Currently, only the following parameters are supported:
Interface
Description
##setConnectionTimeoutInMillis
Timeout to establish a connection ( Unit: milliseconds)
setSocketTimeoutInMillis
Timeout for transmitting data through an open connection (unit: milliseconds)
The above is the detailed content of PHP online speech synthesis. For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn