audioarxiv.audio.base.Audio
- class audioarxiv.audio.base.Audio(rate: float = 140, volume: float = 0.9, voice: str | None = None, pause_seconds: float = 0.1, validate_arguments: bool = True)[source]
Bases:
object
A class to generate audio from text.
Methods
__init__
([rate, volume, voice, ...])A class to configure the audio.
clean_text
(text)Clean the text for smoother reading.
Print available voices with their index and details.
read_article
(article)Read the article aloud, splitting it into sentences.
save_article
(filename, article)Save the article to an audio file.
stop
()Stop the current speech.
Attributes
Get the available voices.
The duration of pause between sentences.
- __init__(rate: float = 140, volume: float = 0.9, voice: str | None = None, pause_seconds: float = 0.1, validate_arguments: bool = True)[source]
A class to configure the audio.
- Parameters:
rate (float, optional) – Number of words per minute. Defaults to 140.
volume (float, optional) – Volume. Defaults to 0.9.
voice (Optional[str], optional) – Voice id. The available voice ids can be found with list_voices(). Defaults to None.
pause_seconds (float, optional) – Duration of pause between sentences. Defaults to 0.1.
validate_arguments (bool) – If True, validate the arguments.
- property available_voices: list
Get the available voices.
- Returns:
The available voices.
- Return type:
list
- clean_text(text: str) str [source]
Clean the text for smoother reading.
‘n’ is replaced with a white space.
- Parameters:
text (str) – Text.
- Returns:
Cleaned text.
- Return type:
str
- property pause_seconds: float
The duration of pause between sentences.
- Returns:
Duration of pause between sentences in second.
- Return type:
float
- read_article(article: str)[source]
Read the article aloud, splitting it into sentences.
- Parameters:
article (str) – Article.