diff options
Diffstat (limited to 'test/transcribe.py')
| -rw-r--r-- | test/transcribe.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/transcribe.py b/test/transcribe.py new file mode 100644 index 0000000..c64f425 --- /dev/null +++ b/test/transcribe.py @@ -0,0 +1,14 @@ +import os +import whisper + +def transcribe_audio(audio_file_path, model_path): + model = whisper.load_model(model_path) + result = model.transcribe(audio_file_path) + text_file_path = os.path.splitext(audio_file_path)[0] + ".txt" + with open(text_file_path, "w") as text_file: + text_file.write(result['text']) + +audio_file_path = 'test.mp3' + +if audio_file_path is not None: + transcribe_audio(audio_file_path, model_path='medium') |
