-
-
Save onyedikachi-david/173283529c1c2bc75d19251cf58aa622 to your computer and use it in GitHub Desktop.
Revisions
-
simonw revised this gist
Nov 3, 2024 . 1 changed file with 7 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,10 @@ # /// script # dependencies = [ # "SpeechRecognition", # "mlx-whisper", # "pyaudio", # ] # /// import speech_recognition as sr import numpy as np -
ivanfioravanti renamed this gist
Nov 3, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ivanfioravanti created this gist
Nov 3, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ # Required packages: # pip install SpeechRecognition mlx-whisper pyaudio # Note: This script requires Apple Silicon Mac for MLX Whisper import speech_recognition as sr import numpy as np import mlx_whisper r = sr.Recognizer() mic = sr.Microphone(sample_rate=16000) print("Listening...") try: with mic as source: r.adjust_for_ambient_noise(source) while True: audio = r.listen(source) # Convert audio to numpy array audio_data = np.frombuffer(audio.get_raw_data(), dtype=np.int16).astype(np.float32) / 32768.0 # Process audio with Apple MLXWhisper model result = mlx_whisper.transcribe(audio_data, path_or_hf_repo="mlx-community/whisper-large-v3-turbo")["text"] # Print the transcribed text print(result) except KeyboardInterrupt: print("Stopped listening.")