pyrit.prompt_converter.AzureSpeechAudioToTextConverter#
- class AzureSpeechAudioToTextConverter(azure_speech_region: str = None, azure_speech_key: str = None, recognition_language: str = 'en-US')[source]#
Bases:
PromptConverter
The AzureSpeechAudioTextConverter takes a .wav file and transcribes it into text. https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-to-text
- Parameters:
azure_speech_region (str) – The name of the Azure region.
azure_speech_key (str) – The API key for accessing the service.
recognition_language (str) – Recognition voice language. Defaults to “en-US”. For more on supported languages, see the following link https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support
- __init__(azure_speech_region: str = None, azure_speech_key: str = None, recognition_language: str = 'en-US') None [source]#
Methods
__init__
([azure_speech_region, ...])convert_async
(*, prompt[, input_type])Converter that transcribes audio to text.
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
recognize_audio
(audio_bytes)Recognize audio file and return transcribed text.
stop_cb
(evt, recognizer)Callback function that stops continuous recognition upon receiving an event 'evt'
transcript_cb
(evt, transcript)Callback function that appends transcribed text upon receiving a "recognized" event
Attributes
- async convert_async(*, prompt: str, input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'audio_path') ConverterResult [source]#
Converter that transcribes audio to text.
- Parameters:
prompt (str) – File path to audio file
input_type (PromptDataType) – Type of data
- Returns:
The transcribed text as a ConverterResult Object
- Return type:
- input_supported(input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error']) bool [source]#
Checks if the input type is supported by the converter
- Parameters:
input_type – The input type to check
- Returns:
True if the input type is supported, False otherwise
- Return type: