Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -123,13 +123,14 @@ def list_dir():
|
|
| 123 |
|
| 124 |
# Filter the list to include only WAV files
|
| 125 |
wav_files = [file for file in files if file.endswith(".wav")]
|
|
|
|
| 126 |
|
| 127 |
-
# Print the
|
| 128 |
-
|
| 129 |
-
|
| 130 |
|
| 131 |
|
| 132 |
-
def combine_wav(source_dir, stamp):
|
| 133 |
# Get a list of all WAV files in the folder
|
| 134 |
wav_files = [file for file in os.listdir(source_dir) if file.endswith(".wav")]
|
| 135 |
|
|
@@ -144,7 +145,7 @@ def combine_wav(source_dir, stamp):
|
|
| 144 |
combined_data.extend(data)
|
| 145 |
|
| 146 |
# Save the combined audio to a new WAV file
|
| 147 |
-
combined_file_path = f"{stamp}.wav"
|
| 148 |
sf.write(combined_file_path, combined_data, sr)
|
| 149 |
|
| 150 |
shutil.rmtree(source_dir)
|
|
@@ -175,7 +176,7 @@ def mms_tts(Input_Text, lang_name="Burmese (mya)"):
|
|
| 175 |
|
| 176 |
for i, sentence in enumerate(sentences):
|
| 177 |
tts.synthesis(sentence, wav_path=f"{user_dir}/s_{str(i).zfill(10)}.wav")
|
| 178 |
-
combined_file_path = combine_wav(user_dir, timestamp)
|
| 179 |
return combined_file_path
|
| 180 |
|
| 181 |
|
|
|
|
| 123 |
|
| 124 |
# Filter the list to include only WAV files
|
| 125 |
wav_files = [file for file in files if file.endswith(".wav")]
|
| 126 |
+
print("Total wav files:", len(wav_files))
|
| 127 |
|
| 128 |
+
# Print the last WAV file
|
| 129 |
+
sorted_list = sorted(wav_files)
|
| 130 |
+
print(lang, sorted_list[-1])
|
| 131 |
|
| 132 |
|
| 133 |
+
def combine_wav(source_dir, stamp, lang):
|
| 134 |
# Get a list of all WAV files in the folder
|
| 135 |
wav_files = [file for file in os.listdir(source_dir) if file.endswith(".wav")]
|
| 136 |
|
|
|
|
| 145 |
combined_data.extend(data)
|
| 146 |
|
| 147 |
# Save the combined audio to a new WAV file
|
| 148 |
+
combined_file_path = f"{stamp}_{lang}.wav"
|
| 149 |
sf.write(combined_file_path, combined_data, sr)
|
| 150 |
|
| 151 |
shutil.rmtree(source_dir)
|
|
|
|
| 176 |
|
| 177 |
for i, sentence in enumerate(sentences):
|
| 178 |
tts.synthesis(sentence, wav_path=f"{user_dir}/s_{str(i).zfill(10)}.wav")
|
| 179 |
+
combined_file_path = combine_wav(user_dir, timestamp, lang_code)
|
| 180 |
return combined_file_path
|
| 181 |
|
| 182 |
|