AwesomeTTS / awesometts-anki-addon

AwesomeTTS text-to-speech add-on for Anki
GNU General Public License v3.0
484 stars 100 forks source link

SSML not working on google cloud TTS #196

Closed luc-vocab closed 3 years ago

luc-vocab commented 3 years ago

write the word on your paper please ! hold write the second time please! doesn't work for example on en-US-wavenet-C

brownbat commented 3 years ago

I'm also seeing errors with Chinese characters that usually worked fine after latest update, for example with "夜" and "官."

When I try "preview" with Google TTS I get 403 forbidden errors, regardless of language or voice selected.

Microsoft's basic Speech API seems to work in the preview window.

Let me know if there's anything I can do to help test.

luc-vocab commented 3 years ago

Can you give me a full string of chinese text which returns an error and tell me which voice you picked ? And also tell me the error please.

brownbat commented 3 years ago

Seems to be any text, vocab or sentences, simplified or traditional, any Wavenet voice.

Anki
---------------------------
AwesomeTTS: Could not play back 科: None of the presets in this group were able to play the input text.
---------------------------
OK   
---------------------------

or...

...
AwesomeTTS: Could not play back 我們 畢 業了!: None of the presets in this group were able to play the input text.

When I'm in the configuration "Manage Service Presets" settings, I put in "Hello" and select a UK voice, I get:


403 Client Error: Forbidden for url: https://texttospeech.googleapis.com/v1/text:synthesize?key=(my key)

My cloud dashboard is also showing my 403s suddenly spiking in the last few days: image

I'm again able to confirm that my API key works with toy python programs I've written, but I'm importing from google.cloud import texttospeech instead of building the request fully on my end like I think ATTS is doing.

brownbat commented 3 years ago

It's unclear from that graph, but the last 200 response I got was at: 2021-03-22T01:07:03.289Z

The first 403 came at: 2021-03-22T19:05:33.289Z

luc-vocab commented 3 years ago

are you using a free key ?

brownbat commented 3 years ago

I'm not using a public key, it's my personal key. But while I have billing set up for Google cloud services, I haven't hit the threshold to pay anything yet.

luc-vocab commented 3 years ago

Would you be able to try the steps here https://github.com/AwesomeTTS/awesometts-anki-addon/wiki/Debug-Logging and attempt to trigger the problematic case, so that I can understand what is happening ?

brownbat commented 3 years ago

Attached, let me know if this helps: awesometts.log

(I ctrl+h'd my personal key, but also confirmed that key is working, both from my cloud dashboard and from using it in other applications.)

EDIT: First used "Hello" then various Chinese short phrases, words, sentences. From the logfile it looks like everything in the "Evaluating Rule" preprocessing steps went fine, to save you staring at Chinese characters wondering if the transformations went correctly.

The post is validated before sending, just gets a 403 from Google for some reason.

20210324-13:22:15,472 INFO     [ttsplayer.py:107] playing back text with group: Chinese, text: 他掌握著公司的大權。.
20210324-13:22:15,472 DEBUG    [router.py:388] Call for 'googletts' w/ {'voice': 'cmn-CN-Wavenet-C', 'speed': 1.0, 'pitch': 0.0, 'profile': 'default'}
20210324-13:22:15,472 DEBUG    [router.py:696] Validated and normalized 'voice', 'speed', 'pitch', 'profile' with failure count of 0
20210324-13:22:15,472 DEBUG    [router.py:402] Parsed call to 'googletts' w/ {'voice': 'cmn-CN-Wavenet-C', 'speed': 1.0, 'pitch': 0.0, 'profile': 'default'} and "他掌握著公司的大權。" at C:\Users\thomas\AppData\Roaming\Anki2\addons21\1436550454\awesometts\.cache\googletts-3b8484db-28704521-a1007280-70b99611-00dfdea0.mp3 (cache miss)
20210324-13:22:15,473 DEBUG    [router.py:938] Spawned thread [4]; pool={3: {'callback': <function Router.__call__.<locals>.completion_callback at 0x0000020D69BADA60>, 'done': True, 'worker': <1436550454.awesometts.router._Worker object at 0x0000020D69B91C20>}, 4: {'callback': <function Router.__call__.<locals>.completion_callback at 0x0000020D008DCD30>, 'done': False, 'worker': <1436550454.awesometts.router._Worker object at 0x0000020D659C9CC0>}}
20210324-13:22:15,475 DEBUG    [connectionpool.py:971] Starting new HTTPS connection (1): texttospeech.googleapis.com:443
20210324-13:22:15,567 DEBUG    [connectionpool.py:452] https://texttospeech.googleapis.com:443 "POST /v1/text:synthesize?key=[REDACTED KEY] HTTP/1.1" 403 None
20210324-13:22:15,571 DEBUG    [router.py:954] Exception from thread [4] (403 Client Error: Forbidden for url: https://texttospeech.googleapis.com/v1/text:synthesize?key=[REDACTED KEY]); executing callback
!!! Traceback (most recent call last):
!!!   File "C:\Users\thomas\AppData\Roaming\Anki2\addons21\1436550454\awesometts\router.py", line 1028, in run
!!!     self._task()
!!!   File "C:\Users\thomas\AppData\Roaming\Anki2\addons21\1436550454\awesometts\router.py", line 558, in task
!!!     service['instance'].run(text, options, path)
!!!   File "C:\Users\thomas\AppData\Roaming\Anki2\addons21\1436550454\awesometts\service\googletts.py", line 469, in run
!!!     r.raise_for_status()
!!!   File "requests\models.py", line 943, in raise_for_status
!!! requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://texttospeech.googleapis.com/v1/text:synthesize?key=[REDACTED KEY]
!!! 
brownbat commented 3 years ago

Ok, it's the key application limits.

image

I don't know why these POST requests seem to be coming from a different IP address, but I had to remove the IP whitelisting for the key before it would work.

This is a little dangerous, so maybe I can tune a whitelist to only let a few IPs through, but it explains a ton.

Especially why VPNs and proxies have issues.

luc-vocab commented 3 years ago

Great to hear, thank you. OK to close this issue then ?

brownbat commented 3 years ago

Yup, wasn't sure if you had it open originally for a different reason. Sorry for hijacking if this was unrelated.