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

Feature/fix isse 35 #38

Open freddiefujiwara opened 3 years ago

freddiefujiwara commented 3 years ago

I am well aware that this is a very experimental and tricky implementation. Just as you also mentioned in https://github.com/zlargon/google-tts/issues/33. google provided a new API. version 0.0.6 is also provisional and will probably not be available any time someday.

Here's my idea

  1. For backward compatibility, tts is a async function returns url
  2. Make a temporary httpd because the new API provides audio data(audio/mpeg) and does not provide any mp3 url
  3. This httpd shuts down once it receives a request
  4. httpd listens with an unused TCP port and the external ip of the running server

I don't want you to merge this PR soon, but I'd love to hear your ideas!

coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 97d2c45847a49d222ead665b6cdb7ae18925ffce on freddiefujiwara:feature/fix-isse-35 into 031b0d63958f1abf62b743d96d43c60248f270f9 on zlargon:master.

zlargon commented 3 years ago

Hi @freddiefujiwara, thank you for your PR. I prefer to have different way to implement the new Google TTS API into this library.

I do realize there is no simple way to generate the audio URL by the base64 text, and it's awesome to see you're trying to solve it in this PR. However, it seems that your solution will consume too many computer resources to find an available port and launch a temporary server for each request, especially when handling a large number of requests concurrently.

I would prefer to keep the library simple and general. So, I decide to implement the new Google TTS API in version 2.0.0 and let users decide whether audio URL or Base64 text is the best way for their use cases. (Audio URL has not been removed from this library yet because we don't know whether Google TTS will keep or remove the original API. We can just keep it until Google officially remove original API.)

You can find more details about version 2.0.0 at README and CHANGELOG. Thanks.