(2.0.0) woohoo, first major version bump!
Some checks failed
Actions / build (push) Successful in 8s
Actions / lint (push) Failing after 13s
Actions / docs (push) Successful in 23s

bunch of stuff this update, including a full documentation site (still a WIP)
there is now a cache created whenever an instance of `FloweryAPI` is instantiated, so you don't have to query the api and iterate through the api response to retrieve a single voice anymore!
function names have also been changed with this update, hence the major version bump. `get_tts()`, `get_voices()`, and `get_voice()` have been renamed to `fetch_tts()`, `fetch_voices()`, and `fetch_voice()` respectively. `get_voices()` still exists, but with different functionality (that method retrieves voices from the internal cache instead of querying the flowery api)

!BREAKING
This commit is contained in:
cswimr 2024-09-18 09:55:25 -04:00
parent 81dea4c8a2
commit cb87400278
Signed by: cswimr
GPG key ID: 3813315477F26F82
17 changed files with 1489 additions and 36 deletions

View file

@ -20,16 +20,10 @@ 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():
if 'en' in voice.language.code:
api.config.logger.info(voice)
async def test_get_tts():
"""Test the get_tts method"""
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)
async def test_fetch_tts():
"""Test the fetch_tts method"""
voice = api.get_voices(voice_id=ALEXANDER)[0]
tts = await api.fetch_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)
@ -37,12 +31,10 @@ async def test_get_tts():
api.config.logger.error(e, exc_info=True)
long_string = 'a' * 2049
try:
await api.get_tts(text=long_string)
await api.fetch_tts(text=long_string)
except ValueError as e:
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")
asyncio.run(test_get_voices())
api.config.logger.info("testing get_tts")
asyncio.run(test_get_tts())
api.config.logger.info("testing fetch_tts")
asyncio.run(test_fetch_tts())