You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importkeyboardfromtimeimportsleepfromrich.consoleimportConsolefromrich.liveimportLiveconsole=Console()
is_recording=Falsedeftoggle_recording():
globalis_recordingis_recording=notis_recordingifis_recording:
console.print('[bold green]Recording started...[/bold green]')
else:
console.print('[bold red]Recording stopped.[/bold red]')
defprocess_text(text):
print("Text", text)
defmain():
fromRealtimeSTTimportAudioToTextRecorderrecorder=AudioToTextRecorder()
withLive() aslive:
whileTrue:
try:
# Press 'r' to start/stop recordingifkeyboard.is_pressed('r'):
toggle_recording()
sleep(0.5) # Debounce# If recording is on, process textifis_recording:
recorder.text(process_text)
sleep(1) # Simulate processing intervalexceptKeyboardInterrupt:
live.stop()
print("Exiting program...")
breakif__name__=="__main__":
try:
main()
exceptKeyboardInterrupt:
console.print("[bold red]Transcription stopped by user. Exiting...[/bold red]")
exit(0)
Above code runs fine on my end (only thing is, the recorder.text() call is blocking, so you can’t stop recording unless you handle the keyboard check in a separate thread.).
Could you share your full code so I can try to reproduce the issue?
Huge shootout for the work done!! Need help
Tried implemeting using Keyboard Package like the above
gives this error:
The text was updated successfully, but these errors were encountered: