(1.0.2) added get_voice() method and added handling for if the request code of get_tts() is between 400 and 600
This commit is contained in:
parent
8f52fda97c
commit
d585072d3e
4 changed files with 24 additions and 4 deletions
|
@ -16,6 +16,10 @@ root.addHandler(handler)
|
|||
|
||||
api = FloweryAPI(FloweryAPIConfig())
|
||||
|
||||
ALEXANDER = "fa3ea565-121f-5efd-b4e9-59895c77df23" # TikTok
|
||||
JACOB = "38f45366-68e8-5d39-b1ef-3fd4eeb61cdb" # Microsoft Azure
|
||||
STORMTROOPER = "191c5adc-a092-5eea-b4ff-ce01f66153ae" # TikTok
|
||||
|
||||
async def test_get_voices():
|
||||
"""Test the get_voices method"""
|
||||
async for voice in api.get_voices():
|
||||
|
@ -24,7 +28,8 @@ async def test_get_voices():
|
|||
|
||||
async def test_get_tts():
|
||||
"""Test the get_tts method"""
|
||||
tts = await api.get_tts(text="BLAST HIM!", voice="191c5adc-a092-5eea-b4ff-ce01f66153ae")
|
||||
voice = await api.get_voice(voice_id=ALEXANDER)
|
||||
tts = await api.get_tts(text="Sphinx of black quartz, judge my vow. The quick brown fox jumps over a lazy dog.", voice=voice)
|
||||
try:
|
||||
with open('test.mp3', 'wb') as f:
|
||||
f.write(tts)
|
||||
|
@ -34,7 +39,7 @@ async def test_get_tts():
|
|||
try:
|
||||
await api.get_tts(text=long_string)
|
||||
except ValueError as e:
|
||||
api.config.logger.error(e, exc_info=True)
|
||||
api.config.logger.error("This is expected to fail:\n%s", e, exc_info=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
api.config.logger.info("testing get_voices")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue