diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2025-03-31 14:30:38 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-03-31 14:30:57 +0530 |
| commit | 0f188ea1e638e6abddb03d49b9209c703081b2fe (patch) | |
| tree | cfe69bb82158fccf9eb4d5737d0c9c1603c5e1f1 /test/transcribe.py | |
| parent | 97d1df0cd10f9f4adc1991cc8067cc8f1d3978cf (diff) | |
update
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') |
