My code looks like below and it is setupped in azure in such a way that the trigger is happening properly but in result I'm getting some buffer or encoded values to be check:
- output result is not genrating a plain text as a transcription result we are getting some audio buffer or an encoded results that need to be fixed 2.sending the audio files they are in .wav format itself hence their is no format issue i thing
import logging
import azure.functions as func
import azure.cognitiveservices.speech as speechsdk
from azure.storage.blob import BlobServiceClient, ContentSettings
# Azure Speech Service configuration
speech_key = "speech-key"
service_region = "eastus"
# Configure Speech Recognizer
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
def main(blob: func.InputStream, outputBlob: func.Out\[str\]):
logging.info(f"Python blob trigger function processed blob\\n"
f"Name: {blob.name}\\n"
f"Blob Size: {blob.length} bytes")
# Get the audio data from the blob
audio_data = blob.readall()
# Create an audio stream from the audio data
audio_stream = speechsdk.audio.AudioDataStream(audio_data)
# Create a speech recognizer
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_stream)
# Perform speech recognition
result = speech_recognizer.recognize_once()
# Get the transcript
transcript = result.text if result.reason == speechsdk.ResultReason.RecognizedSpeech else ""
# Save transcript as a text file
output_file = "output.txt"
with open(output_file, "w") as file:
file.write(transcript)
# Save transcript to a new blob
connection_string = "DefaultEndpointsProtocol=https;AccountName=scribeemrnewtesting8a49;AccountKey=RvyepyfHuKQjIrbPLSnx36zNB65l64kUurdSFi903DhXdz+pzbFTgpuNk6yviESmPlIVDFqMkjxU+AStRPdFAA==;EndpointSuffix=core.windows.net"
output_container_name = "text-output"
blob_name = blob.name.replace(".wav", ".txt")
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
output_container_client = blob_service_client.get_container_client(output_container_name)
# Upload transcript to output blob container/
output_blob_client = output_container_client.get_blob_client(blob_name)
with open(output_file, "rb") as file:
output_blob_client.upload_blob(file, overwrite=True, content_settings=ContentSettings(content_type='text/plain'))
blob.delete()
logging.info(f"Transcription completed and saved to the out-blob container: {transcript}")
outputBlob.set(transcript)
getting output as: RIFF�� WAVEfmt �> } data�� �������� �� ! �� �� �� % ���� "
type here
expected : A plain text which has transcription as per the above logic