Jack
commited on
Commit
·
8f8089e
1
Parent(s):
97bfe69
added various files
Browse files
app.py
CHANGED
@@ -73,28 +73,9 @@ To get started, upload the audio below.
|
|
73 |
"""
|
74 |
await cl.Message(content=welcome_message).send()
|
75 |
|
76 |
-
|
77 |
-
# Log any errors that occur during session initialization
|
78 |
-
print(f"Error during on_chat_start: {str(e)}")
|
79 |
-
|
80 |
-
# Stop chat session cleanup
|
81 |
-
@cl.on_stop
|
82 |
-
async def on_chat_stop():
|
83 |
-
# Clean up any session data or resources here, if needed
|
84 |
-
print("Session ended, resources cleaned up.")
|
85 |
-
|
86 |
-
# Handle incoming chat
|
87 |
-
@cl.on_message
|
88 |
-
async def handle_message(message: cl.Message):
|
89 |
-
try:
|
90 |
-
# Retrieve transcription counter for the user session
|
91 |
-
counter = cl.user_session.get("transcription_counter", 0)
|
92 |
-
counter += 1
|
93 |
-
cl.user_session.set("transcription_counter", counter)
|
94 |
-
|
95 |
-
# Get the uploaded audio file
|
96 |
files = await cl.AskFileMessage(
|
97 |
-
content="",
|
98 |
accept={
|
99 |
"audio/wav": [".wav"],
|
100 |
"audio/mpeg": [".mp3"]
|
@@ -132,5 +113,11 @@ async def handle_message(message: cl.Message):
|
|
132 |
await msg.update(content="Here is the ATC transcription:")
|
133 |
|
134 |
except Exception as e:
|
135 |
-
# Log any errors that occur during
|
136 |
-
print(f"Error during
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
"""
|
74 |
await cl.Message(content=welcome_message).send()
|
75 |
|
76 |
+
# Prompt the user to upload an audio file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
files = await cl.AskFileMessage(
|
78 |
+
content="Please upload your ATC audio file (MP3 or WAV):",
|
79 |
accept={
|
80 |
"audio/wav": [".wav"],
|
81 |
"audio/mpeg": [".mp3"]
|
|
|
113 |
await msg.update(content="Here is the ATC transcription:")
|
114 |
|
115 |
except Exception as e:
|
116 |
+
# Log any errors that occur during session initialization
|
117 |
+
print(f"Error during on_chat_start: {str(e)}")
|
118 |
+
|
119 |
+
# Stop chat session cleanup
|
120 |
+
@cl.on_stop
|
121 |
+
async def on_chat_stop():
|
122 |
+
# Clean up any session data or resources here, if needed
|
123 |
+
print("Session ended, resources cleaned up.")
|