https://github.com/pierrepo/article-SWH-bioinfo-fr
Tip revision: f85d0db6f228b21fc0f5eb3a874bdfdcb0a2dac9 authored by Pierre Poulain on 14 January 2025, 09:50:27 UTC
Add manuscript v1
Add manuscript v1
Tip revision: f85d0db
transcript.py
"""Create video transcript with the Groq API.
Script adapted from the Groq API documentation:
https://console.groq.com/docs/speech-text
"""
from pathlib import Path
from groq import Groq
# Initialize the Groq client
client = Groq()
# Specify the path to the audio file
filename = Path(__file__).parent.absolute() / "audio_clean.mp3"
# Open the audio file
with open(filename, "rb") as audiofile:
# Create a transcription of the audio file
transcription = client.audio.transcriptions.create(
file=(str(filename), audiofile.read()),
model="whisper-large-v3",
response_format="json",
language="fr",
temperature=0.0,
)
# Print the transcription text
print(transcription.text)
