-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (47 loc) · 1.76 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import logging
import keyboard
from asr.asr_manager import ASR
from utils.audio_utils import save_audio
def print_menu():
print("\n===== Whisper ASR CLI Menu =====")
print("1. Record Audio")
print("2. Set Recording Duration")
print("3. Set Output File Path")
print("4. Quit")
def main():
try:
logging.basicConfig(level=logging.INFO)
asr = ASR()
output_path = "output.wav"
recording_duration = 30.0
while True:
print_menu()
choice = input("Enter your choice (1-4): ")
if choice == "1":
try:
asr.record_audio(output_path, max_duration=recording_duration)
except KeyboardInterrupt:
print("\nRecording interrupted. Press 'Ctrl+C' again to exit.")
try:
keyboard.wait("ctrl+c")
except KeyboardInterrupt:
print("\nExiting Whisper ASR CLI. Goodbye!")
break
elif choice == "2":
try:
recording_duration = float(input("Enter recording duration in seconds: "))
except ValueError:
print("Invalid input. Please enter a valid number.")
elif choice == "3":
output_path = input("Enter output file path: ")
elif choice == "4":
print("Exiting Whisper ASR CLI. Goodbye!")
break
else:
print("Invalid choice. Please enter a number between 1 and 4.")
except KeyboardInterrupt:
print("\nQuitting Whisper ASR CLI. Goodbye!")
except Exception as e:
print(f"An error occurred: {str(e)}")
if __name__ == "__main__":
main()