This is absolute garbage python as I am neither a python developer, nor a good developer. I was trying to play around with real time transcriptions. However, it does work!
> * recording
* done recording
Recording saved to file.wav
Press enter to transcribe
/Users/laptop/Development/Personal/Public/pythonProject1/venv/lib/python3.9/site-packages/whisper/transcribe.py:70: UserWarning: FP16 is not supported on CPU; using FP32 instead
warnings.warn("FP16 is not supported on CPU; using FP32 instead")
Detected language: english
Goodbye, I need to go pick up my wife.
Press enter to start recording
Any improvements welcome here.
```
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
if __name__ == '__main__':
seconds = 5
while True:
print("Press enter to start recording")
input()
filename = record_microphone(seconds)
print("Recording saved to " + filename)
print("Press enter to transcribe")
input()
import whisper
model = whisper.load_model("base")
result = model.transcribe(filename)
print(result["text"])
> * recording * done recording Recording saved to file.wav Press enter to transcribe
/Users/laptop/Development/Personal/Public/pythonProject1/venv/lib/python3.9/site-packages/whisper/transcribe.py:70: UserWarning: FP16 is not supported on CPU; using FP32 instead warnings.warn("FP16 is not supported on CPU; using FP32 instead") Detected language: english Goodbye, I need to go pick up my wife. Press enter to start recording
Any improvements welcome here.
``` # This is a sample Python script.
# Press ⌃R to execute it or replace it with your code. # Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
def record_microphone(seconds): import pyaudio import wave
if __name__ == '__main__': seconds = 5 while True: print("Press enter to start recording") input() filename = record_microphone(seconds) print("Recording saved to " + filename) print("Press enter to transcribe") input() import whisper model = whisper.load_model("base") ```