balaramas commited on
Commit
3aa8911
1 Parent(s): b5caf0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
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
- #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
- subprocess.run(["python", "prep_mustc_data_hindi_single.py", "--data-root", d_r, "--task", "st", "--vocab-type", "unigram", "--vocab-size", "8000"])
 
 
 
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
- #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)
106
- #translation_result_text = translation_result.stdout
107
 
108
- #lines = translation_result_text.split("\n")
109
 
110
 
111
  #just for checking the duration from the yaml file of the current input audio
112
- #with open(yam, 'r') as yaml_file:
113
- #data = yaml.safe_load(yaml_file)
114
- #print(data[0]['duration'], " seconds duration")
115
 
116
  output_text=""
117
- #print("\n\n------Translation results are:\n")
118
- #for i in lines:
119
- #if (i.startswith("D-0")):
120
- #print(i.split("\t")[2])
121
- #output_text=i.split("\t")[2]
122
- #break
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