Reputation: 1
I am using google.cloud.speech_v2 client library for python to get the transcription of a short (< 1 min) audio in spanish. It works fine with model = "long", language code = "es-US". Same audio with "chirp" gives only the first part of the transcription.
I am using chirp because I need automatic punctuation. Tried different audios and different chirp model (chirp 2) with the same result.
Here is my code:
def transcribe_chirp(
audio_file: str):
client = SpeechClient(
client_options=ClientOptions(
api_endpoint="us-central1-speech.googleapis.com",
)
)
with open(audio_file, "rb") as f:
audio_content = f.read()
config = cloud_speech.RecognitionConfig(
auto_decoding_config=cloud_speech.AutoDetectDecodingConfig(),
language_codes=["es-US"],
model="chirp",
features=cloud_speech.RecognitionFeatures(
# Enable automatic punctuation
enable_automatic_punctuation=True,
max_alternatives = 2,
enable_word_time_offsets=True
),
)
request = cloud_speech.RecognizeRequest(
recognizer=f"projects/{PROJECT_ID}/locations/us-central1/recognizers/_",
config=config,
content=audio_content,
)
response = client.recognize(request=request)
for result in response.results:
print(f"Transcript: {result.alternatives[0].transcript}")
return response
Upvotes: 0
Views: 30