AidanWelch / google-translate-api

An updated free and unlimited API for Google Translate :dollar: :no_entry_sign:
MIT License
143 stars 20 forks source link

Issue with the speak functionality #32

Closed Ashish-Ranjan-007 closed 1 year ago

Ashish-Ranjan-007 commented 1 year ago

New to development, I am getting this error /node_modules/google-translate-api-x/lib/speak.cjs:66 const result = JSON.parse(translation[2])[0]; ^ TypeError: Cannot read properties of null (reading '0')

I figured it out , the issue appears when the text under single translate using "speak" function exceeds 195 characters. I need help how to convert long texts to mp3.

There are other packages that are able to convert it, but I really wanted to make this package more efficient by adding inputs.

Thanks

AidanWelch commented 1 year ago

The google TTS endpoint only supports a maximum of 200 characters per string, but fortunately, you can split longer strings up into a batch request and it will be still be only 1 api request. Also, error logging was improved in v10.6.6

Ashish-Ranjan-007 commented 1 year ago

Great , thanks for the advice, I am at the final stage of a project now, where I used your translate API, and batch works as a charm. Regards.