24 lines
616 B
Python
24 lines
616 B
Python
import sys
|
|
import whisper
|
|
|
|
def transcribe_audio(audio_path):
|
|
# Load the Whisper model
|
|
model = whisper.load_model("base")
|
|
|
|
# Transcribe the audio file
|
|
print(f"Transcribing: {audio_path} ...")
|
|
result = model.transcribe(audio_path, language="fr")
|
|
|
|
# Print and return transcription
|
|
transcription = result["text"]
|
|
print("\nTranscription:\n")
|
|
print(transcription)
|
|
return transcription
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python transcribe.py path/to/audiofile")
|
|
else:
|
|
audio_file = sys.argv[1]
|
|
transcribe_audio(audio_file)
|