Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -98,28 +98,31 @@ def run_my_code(input_text, language):
|
|
98 |
os.system(f"cp {hi_wav} {data_root}data/tst-COMMON/wav/test.wav")
|
99 |
|
100 |
print("------Starting data prepration------")
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
103 |
print("------Performing translation------")
|
104 |
#subprocess.run(["python", "generate.py", data_root, "--config-yaml", "config_st.yaml", "--gen-subset", "tst-COMMON_st", "--task", "speech_to_text", "--path", model_checkpoint])
|
105 |
-
|
106 |
-
|
107 |
|
108 |
-
|
109 |
|
110 |
|
111 |
#just for checking the duration from the yaml file of the current input audio
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
|
116 |
output_text=""
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
|
124 |
os.system(f"rm {data_root}data/tst-COMMON/wav/test.wav")
|
125 |
return output_text
|
|
|
98 |
os.system(f"cp {hi_wav} {data_root}data/tst-COMMON/wav/test.wav")
|
99 |
|
100 |
print("------Starting data prepration------")
|
101 |
+
subprocess.run(["python", "prep_mustc_data_hindi_single.py", "--data-root", d_r, "--task", "st", "--vocab-type", "unigram", "--vocab-size", "8000"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
102 |
+
|
103 |
+
#For testing
|
104 |
+
#subprocess.run(["python", "prep_mustc_data_hindi_single.py", "--data-root", d_r, "--task", "st", "--vocab-type", "unigram", "--vocab-size", "8000"])
|
105 |
+
|
106 |
print("------Performing translation------")
|
107 |
#subprocess.run(["python", "generate.py", data_root, "--config-yaml", "config_st.yaml", "--gen-subset", "tst-COMMON_st", "--task", "speech_to_text", "--path", model_checkpoint])
|
108 |
+
translation_result = subprocess.run(["python", "generate.py", data_root, "--config-yaml", "config_st.yaml", "--gen-subset", "tst-COMMON_st", "--task", "speech_to_text", "--path", model_checkpoint], capture_output=True, text=True)
|
109 |
+
translation_result_text = translation_result.stdout
|
110 |
|
111 |
+
lines = translation_result_text.split("\n")
|
112 |
|
113 |
|
114 |
#just for checking the duration from the yaml file of the current input audio
|
115 |
+
with open(yam, 'r') as yaml_file:
|
116 |
+
data = yaml.safe_load(yaml_file)
|
117 |
+
print(data[0]['duration'], " seconds duration")
|
118 |
|
119 |
output_text=""
|
120 |
+
print("\n\n------Translation results are:\n")
|
121 |
+
for i in lines:
|
122 |
+
if (i.startswith("D-0")):
|
123 |
+
print(i.split("\t")[2])
|
124 |
+
output_text=i.split("\t")[2]
|
125 |
+
break
|
126 |
|
127 |
os.system(f"rm {data_root}data/tst-COMMON/wav/test.wav")
|
128 |
return output_text
|