Zack Saadioui
8/27/2024
1
2
bash
curl https://ollama.ai/install.sh | sh
1
2
bash
ollama pull whisper
1
assistant.yaml
1
2
``
In this example, replace
1
PyAudio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
import pyaudio import numpy as np import whisper # Initialize Whisper model model = whisper.load_model("base") # To be handled in a thread for non-blocking audio recording def record(): # Audio configuration CHUNK = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 16000 stream = pyaudio.PyAudio().open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK) print('Listening...') while True: data = stream.read(CHUNK) audio = np.frombuffer(data, dtype="int16") # Transcribe the audio chunk result = model.transcribe(audio) print(result["text"]) # Output the transcription # Run the recording function record()
Copyright © Arsturn 2024