AsyncFakeYou
AsyncFakeYou is an asynchronous Python library for interacting with the FakeYou Text-to-Speech API. It allows you to submit TTS requests, track their status, and download the resulting audio files, all in an asynchronous manner using asyncio, aiohttp and aiofiles.
Features
- Asynchronous requests to FakeYou TTS API.
- Generation with parallel execution control
- Handle user authentication with session cookies
Installation
pip install asyncfakeyou
Simple usage
You can obtain a direct URL to the generated audio file.
from asyncfakeyou import AsyncAudioGen
import asyncio
async def text_to_speech():
gen = AsyncAudioGen(cookies="your_cookie_string")
audio_url = await gen.fetch_audio("model_token_here", "sample_text")
print(audio_url)
asyncio.run(text_to_speech())
Or you can download the generated audio file to a specified directory.
from asyncfakeyou import AsyncAudioGen
import asyncio
async def text_to_speech():
gen = AsyncAudioGen(cookies="your_cookie_string")
audio_url = await gen.fetch_and_save_audio("model_token_here", "sample_text",
output_path="./audio",
filename="generated_audio.wav")
print(audio_url)
asyncio.run(text_to_speech())
How to obtain cookies?
The cookies parameter of the AsyncAudioGen class is optional. However, I recommend setting it as it will give you higher queue priority, even without a paid subscription. If you have a premium account, you will be able to take advantage of all its benefits through this API.
from asyncfakeyou import receive_cookies
import asyncio
async def get_my_cookies():
cookies = await receive_cookies("your_username_or_email", "your_password")
print(cookies)
asyncio.run(get_my_cookies())
Parallel execution
If you need to generate multiple audio files, you can speed up the process by using fetch_tasks and fetch_and_save_tasks. These methods handle a fixed number of tasks in parallel (concurrent_tasks parameter) and automatically retry failed requests. The default value for concurrent_tasks is 3, but you can tweak this parameter.
You can iterate through the direct URLs to the generated audio files.
from asyncfakeyou import AsyncAudioGen
import asyncio
async def multiple_text_to_speech():
gen = AsyncAudioGen(cookies="your_cookie_string")
audio_tasks = [
("model_token_1", "sample_text_1"),
("model_token_2", "sample_text_2"),
("model_token_3", "sample_text_3")
]
async for audio_url in gen.fetch_tasks(audio_tasks):
print(audio_url)
asyncio.run(multiple_text_to_speech())
Or you can download the generated audio files to a specified directory.
from asyncfakeyou import AsyncAudioGen
import asyncio
async def multiple_text_to_speech():
gen = AsyncAudioGen(cookies="your_cookie_string")
audio_tasks = [
("model_token_1", "sample_text_1", "filename1.wav"),
("model_token_2", "sample_text_2", "filename2.wav"),
("model_token_3", "sample_text_3", "filename3.wav")
]
await gen.fetch_and_save_tasks(audio_tasks, output_path="./audio")
asyncio.run(multiple_text_to_speech())
Contributing
Contributions are welcome! Please fork the repository and create a pull request with your improvements.
Metadata
Release files for asyncfakeyou 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asyncfakeyou-0.1.2.tar.gz | 7.9 kB | Without provenance | Details for asyncfakeyou-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asyncfakeyou-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for asyncfakeyou-0.1.2-py3-none-any.whl |
Total release size: 15.4 kB
Release files / asyncfakeyou-0.1.2.tar.gz
| Download URL | asyncfakeyou-0.1.2.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cae32fc2ccb828cb94341eb27dd0642a416dcac96d9bc6167a8a35747d07afde
|
|
BLAKE2b-256 checksum How to use checksums |
506114a82738b298ed58c242ec60e34f6bff322c0f1a96803a545b8e5106100d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / asyncfakeyou-0.1.2-py3-none-any.whl
| Download URL | asyncfakeyou-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c65eb68316e6ce7f53e58c06d77074d3ca89fd247bae061aeb9d45f054530821
|
|
BLAKE2b-256 checksum How to use checksums |
18f5659e1ee469cfef9c242fad477d5c2350398da155634a39fa5ef877527302
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for asyncfakeyou 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.