update feature for real time transcription locally

This commit is contained in:
gokul
2023-06-20 17:37:01 +05:30
parent 60072062af
commit 7fd02607f6
5 changed files with 41 additions and 13 deletions

View File

@@ -14,23 +14,28 @@ WHISPER_MODEL_SIZE = config['DEFAULT']["WHISPER_MODEL_SIZE"]
FRAMES_PER_BUFFER = 8000
FORMAT = pyaudio.paInt16
CHANNELS = 1
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5
RECORD_SECONDS = 15
def main():
p = pyaudio.PyAudio()
AUDIO_DEVICE_ID = -1
for i in range(p.get_device_count()):
if p.get_device_info_by_index(i)["name"] == "ref-agg-input":
AUDIO_DEVICE_ID = i
audio_devices = p.get_device_info_by_index(AUDIO_DEVICE_ID)
stream = p.open(
format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=FRAMES_PER_BUFFER
frames_per_buffer=FRAMES_PER_BUFFER,
input_device_index=audio_devices['index']
)
pipeline = FlaxWhisperPipline("openai/whisper-" + WHISPER_MODEL_SIZE,
pipeline = FlaxWhisperPipline("openai/whisper-" + config["DEFAULT"]["WHISPER_REAL_TIME_MODEL_SIZE"],
dtype=jnp.float16,
batch_size=16)
@@ -48,8 +53,7 @@ def main():
listener = keyboard.Listener(on_press=on_press)
listener.start()
print("Listening...")
print("Attempting real-time transcription.. Listening...")
while proceed:
try:
frames = []