-
-
Save NickyDark1/d44537bdedd727f415b8d69b0ca2e107 to your computer and use it in GitHub Desktop.
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 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