Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,14 +36,14 @@ reader = TextFileReader()
|
|
36 |
# Define a function to save the text lines to a file
|
37 |
def save_text_lines(file):
|
38 |
lines = reader.read_lines(file)
|
39 |
-
with open("
|
40 |
f.write("\n".join(reader.lines))
|
41 |
return lines
|
42 |
|
43 |
# Define a function to save the audio file and corresponding text
|
44 |
def save_audio_text(audio, text):
|
45 |
-
if not os.path.exists("
|
46 |
-
os.makedirs("/
|
47 |
|
48 |
# Debugging to print out the structure of the audio variable
|
49 |
print("Received audio data:", audio)
|
@@ -51,8 +51,8 @@ def save_audio_text(audio, text):
|
|
51 |
# Check if audio is a dictionary and contains 'data'
|
52 |
if isinstance(audio, dict) and 'data' in audio:
|
53 |
audio_data = audio['data']
|
54 |
-
audio_path = f"/
|
55 |
-
text_path = f"/
|
56 |
|
57 |
with open(audio_path, "wb") as f:
|
58 |
f.write(audio_data)
|
|
|
36 |
# Define a function to save the text lines to a file
|
37 |
def save_text_lines(file):
|
38 |
lines = reader.read_lines(file)
|
39 |
+
with open("text_lines.txt", "w") as f:
|
40 |
f.write("\n".join(reader.lines))
|
41 |
return lines
|
42 |
|
43 |
# Define a function to save the audio file and corresponding text
|
44 |
def save_audio_text(audio, text):
|
45 |
+
if not os.path.exists("recordings"):
|
46 |
+
os.makedirs("/recordings")
|
47 |
|
48 |
# Debugging to print out the structure of the audio variable
|
49 |
print("Received audio data:", audio)
|
|
|
51 |
# Check if audio is a dictionary and contains 'data'
|
52 |
if isinstance(audio, dict) and 'data' in audio:
|
53 |
audio_data = audio['data']
|
54 |
+
audio_path = f"/recordings/line_{reader.current_index}.wav"
|
55 |
+
text_path = f"/recordings/line_{reader.current_index}.txt"
|
56 |
|
57 |
with open(audio_path, "wb") as f:
|
58 |
f.write(audio_data)
|