Speech
- class terminusgps.aws.speech.AsyncSpeechSynthesisManager(bucket_name: str | None = None, region_name: str = 'us-east-1')[source]
Public Data Attributes:
An AWS region name.
The AWS bucket that will host audio files.
Public Methods:
__init__
([bucket_name, region_name])__aenter__
()Creates an asyncronous session and client.
__aexit__
(exc_type, exc_val, exc_tb)Destroys the asyncronous session.
synthesize_speech
(message[, format, ...])Synthesizes the message into an audio file and saves it to the S3 bucket.
synthesize_speech_batch
(messages[, format, ...])Synthesizes a sequence of messages into audio files and saves them to the S3 bucket.
- async synthesize_speech(message: str, format: str = 'ogg_vorbis', sample_rate: int = 22050, language_code: str = 'en-US') None [source]
Synthesizes the message into an audio file and saves it to the S3 bucket.
- Parameters:
- Returns:
The audio file URI.
- Return type:
Usage
import asyncio
from terminusgps.aws.speech import AsyncSpeechSynthesisManager
async def main() -> None:
async with AsyncSpeechSynthesisManager("my-bucket-name") as manager:
message: str = "This message should be read aloud and saved as a file in an S3 bucket."
await manager.synthesize_speech(message)
if __name__ == "__main__":
asyncio.run(main())