synthesizer¶
This module contains the following classes:
Synthesizer
, for synthesizing text fragments into an audio file, along with the corresponding time anchors.
Warning
This module might be refactored in a future version
-
class
aeneas.synthesizer.
Synthesizer
(rconf=None, logger=None)[source]¶ A class to synthesize text fragments into an audio file, along with the corresponding time anchors.
Parameters: - rconf (
RuntimeConfiguration
) – a runtime configuration - logger (
Logger
) – the logger object
Raises: OSError: if a custom TTS engine is requested but it cannot be loaded
Raises: ImportError: if the AWS Polly TTS API wrapper is requested but the
boto3
module is not installed, or if the Nuance TTS API wrapper is requested but the``requests`` module is not installed-
ALLOWED_VALUES
= ['aws', 'custom', 'espeak', 'espeak-ng', 'festival', 'macos', 'nuance']¶ List of all the allowed values
-
AWS
= 'aws'¶ Select AWS Polly TTS API wrapper
-
CUSTOM
= 'custom'¶ Select custom TTS engine wrapper
-
ESPEAK
= 'espeak'¶ Select eSpeak wrapper
-
ESPEAKNG
= 'espeak-ng'¶ Select eSpeak-ng wrapper
-
FESTIVAL
= 'festival'¶ Select Festival wrapper
-
MACOS
= 'macos'¶ Select macOS “say” wrapper
-
NUANCE
= 'nuance'¶ Select Nuance TTS API wrapper
-
clear_cache
()[source]¶ Clear the TTS cache, removing all cache files from disk.
New in version 1.6.0.
-
output_audio_format
¶ Return a tuple
(codec, channels, rate)
specifying the audio format generated by the actual TTS engine.Return type: tuple
-
synthesize
(text_file, audio_file_path, quit_after=None, backwards=False)[source]¶ Synthesize the text contained in the given fragment list into a
wav
file.Return a tuple
(anchors, total_time, num_chars)
.Parameters: - text_file (
TextFile
) – the text file to be synthesized - audio_file_path (string) – the path to the output audio file
- quit_after (float) – stop synthesizing as soon as reaching this many seconds
- backwards (bool) – if
True
, synthesizing from the end of the text file
Return type: tuple
Raises: TypeError: if
text_file
isNone
or not an instance ofTextFile
Raises: OSError: if
audio_file_path
cannot be writtenRaises: OSError: if
tts=custom
in the RuntimeConfiguration andtts_path
cannot be readRaises: ValueError: if the TTS engine has not been set yet
- text_file (
- rconf (