Google TTS – Text To Speech Voices – Google Text To Speech

Google TTS – Google Text To Speech API

Convert Text Into Speech using Google Text To Speech API And Save file as MP3. You can convert MP3 file as .wav file extension using sox.exe with coldfusion.

Google TTS Example

<cfset ttstext = “hello this a test to check Text to speech audio file. 1032 or 1 0 3 2 or 1,0,3,2 .Thankyou”>
<cfset FileOutputPath = ExpandPath( “./audiofiles” ) />
<cfset uniqueStr = right(CreateUUID(),5) />
<cfset filename = ‘Output.mp3’ />
<cfset OutputFileFullPath = FileOutputPath & ‘/’ & filename />
<cfoutput>
<cfsavecontent variable=”Json” >
{
“audioConfig”: {
“audioEncoding”: “MP3”,
“pitch”: “0.00”,
“speakingRate”: “1.00”
},
“input”: {
“text”: “#ttstext#”
},
“voice”: {
“languageCode”: “en-US”,
“name”: “en-US-Wavenet-D”,
“ssmlGender”:”MALE”
}
}
</cfsavecontent>
</cfoutput>
<!—<cfdump var=”#json#”>—>

<cfhttp url=”https://texttospeech.googleapis.com/v1/text:synthesize?fields=audioContent&key=xxxxxxxxxxxxxxxxxxxxx” method=”post” result=”getData”>
<cfhttpparam type=”body” value=”#Json#” >
</cfhttp>
<cfset audioContent = DeserializeJSON(getData.Filecontent).audioContent />
<cffile action=”write” file=”#OutputFileFullPath#” output=”#toBinary(audioContent)#”>

//Change MP3 Into WAV
<cfexecute name=”C:\sox-14-4-2\sox.exe”
arguments=”#FileOutputPath#\#filename#.mp3 -b 16 -r 11025 -c 1 #FileOutputPath#\#filename#.wav”
timeout=”20″/>

Read more:

Pin It on Pinterest