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

404 on texts over 200 characters #5

Closed minemidnight closed 7 years ago

minemidnight commented 7 years ago

Any text that is over 200 characters returns a URL that just 404's.

zlargon commented 7 years ago

Thanks for your report. This is the limitation of Google TTS API (for free), and I will add the statement to README.

minemidnight commented 7 years ago

Is there a way to get streams from multiple URLs and combine them to overcome this? Of course it would remove the "just returns a url" functionality, but would fix this.

zlargon commented 7 years ago

Yes, that's exactly how "Google Translate" is doing on their website:

First, cut off the long paragraph into many small sentences, in order to make all the amount of characters (of sentences) less than 200.

Then, send requests to Google Translate API and play the audios in sequence.

google-translate-network

In my opinion, combining multiple URLs would be an up-level functionality, which is not suitable to be implemented here. However, I think there still are two things I can do:

  1. Check the input: If the amount of characters is over 200, then throw an exception. This would be updated in next release 0.0.2.

  2. Add an example to deal with long characters, as same as "Google Translate" do in their website. Thus, the user can reference the sample codes.

Thanks for your great suggestion, and hope you would like it. 👍 Leon

zlargon commented 7 years ago
  1. Library has been upgraded to 0.0.2

  2. An example for long characters: https://github.com/zlargon/google-tts/blob/master/example/long-english-characters.js