zlargon / google-tts

Google TTS (Text-To-Speech) for node.js
https://www.npmjs.com/package/google-tts-api
MIT License
279 stars 56 forks source link

lang code en-US,en-AU not working with getAudioBase64, getAllAudioBase64 #45

Open 1sharth opened 3 years ago

1sharth commented 3 years ago

The sample code present in the examples is not working:

// get base64 text
googleTTS.getAudioBase64('Hello World', {
     lang: 'en-US',
     slow: false,
     host: 'https://translate.google.com',
     timeout: 10000,
})
.then(console.log) // base64 text
.catch(console.error);

Error: lang "en-US" might not exist

It successfully returned base64 output for language codes: 'en', 'es'. en-Us, en-AU are working fine for getAudioUrl,getAllAudioUrls functions though.

SuspiciousLookingOwl commented 3 years ago

Seems like this is an expected behavior, when sending a request to the endpoint to get the base64 data, we only sends 2 characters country code image

With exception for Chinese Simplified and Traditional (zh-CN and zh-TW respectively)

zlargon commented 3 years ago

Thank you for reporting this issue.

Looks like google translate API has a minor change. I will some updates next release.

Thanks