pyrit.prompt_converter.AzureSpeechTextToAudioConverter#
- class AzureSpeechTextToAudioConverter(azure_speech_region: str = None, azure_speech_key: str = None, synthesis_language: str = 'en_US', synthesis_voice_name: str = 'en-US-AvaNeural', output_format: Literal['wav', 'mp3'] = 'wav')[source]#
Bases:
PromptConverter
The AzureSpeechTextToAudio takes a prompt and generates a wave file. https://learn.microsoft.com/en-us/azure/ai-services/speech-service/text-to-speech :param azure_speech_region: The name of the Azure region. :type azure_speech_region: str :param azure_speech_key: The API key for accessing the service. :type azure_speech_key: str :param synthesis_language: Synthesis voice language :type synthesis_language: str :param synthesis_voice_name: Synthesis voice name, see URL :type synthesis_voice_name: str :param For more details see the following link for synthesis language and synthesis voice: :param https: //learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support :param filename: File name to be generated. Please include either .wav or .mp3 :type filename: str :param output_format: Either wav or mp3. Must match the file prefix. :type output_format: str
- __init__(azure_speech_region: str = None, azure_speech_key: str = None, synthesis_language: str = 'en_US', synthesis_voice_name: str = 'en-US-AvaNeural', output_format: Literal['wav', 'mp3'] = 'wav') None [source]#
Methods
__init__
([azure_speech_region, ...])convert_async
(*, prompt[, input_type])Converts the given prompts into a different representation
convert_tokens_async
(*, prompt[, ...])Converts substrings within a prompt that are enclosed by specified start and end tokens.
get_identifier
()input_supported
(input_type)Checks if the input type is supported by the converter
Attributes
alias of
Literal
['wav', 'mp3']- async convert_async(*, prompt: str, input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text') ConverterResult [source]#
Converts the given prompts into a different representation
- Parameters:
prompt – The prompt to be converted.
- Returns:
The converted representation of the prompts.
- Return type: