-
-
Save vikramsoni2/ce1eff99769bff8351965aff5855f43a to your computer and use it in GitHub Desktop.
This file contains 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 characters
#pip install git+https://github.com/huggingface/transformers.git | |
import datetime | |
import sys | |
from transformers import pipeline | |
from transformers.pipelines.audio_utils import ffmpeg_microphone_live | |
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=0) | |
sampling_rate = pipe.feature_extractor.sampling_rate | |
start = datetime.datetime.now() | |
chunk_length_s = 5 | |
stream_chunk_s = 0.1 | |
mic = ffmpeg_microphone_live( | |
sampling_rate=sampling_rate, | |
chunk_length_s=chunk_length_s, | |
stream_chunk_s=stream_chunk_s, | |
) | |
print("Start talking...") | |
for item in pipe(mic): | |
sys.stdout.write("\033[K") | |
print(item["text"], end="\r") | |
if not item["partial"][0]: | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment