Spaces:
Sleeping
Sleeping
Commit
•
cf0d89b
1
Parent(s):
3a282c5
Update translate.py
Browse files- translate.py +16 -7
translate.py
CHANGED
@@ -28,13 +28,13 @@ class Translate:
|
|
28 |
return audio_path
|
29 |
|
30 |
def gender_detection(self):
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
return
|
38 |
|
39 |
|
40 |
|
@@ -208,3 +208,12 @@ class Translate:
|
|
208 |
# Write the video with translated audio to the output file
|
209 |
video.write_videofile(output_video_path, codec="libx264", audio_codec="aac")
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
return audio_path
|
29 |
|
30 |
def gender_detection(self):
|
31 |
+
gender_model_url = "https://salman11223-gender-detection.hf.space/--replicas/wml9f/"
|
32 |
+
gender_client = Client(gender_model_url)
|
33 |
+
gender = gender_client.predict(
|
34 |
+
'audio.wav', api_name="/predict"
|
35 |
+
)
|
36 |
+
print(gender)
|
37 |
+
return gender
|
38 |
|
39 |
|
40 |
|
|
|
208 |
# Write the video with translated audio to the output file
|
209 |
video.write_videofile(output_video_path, codec="libx264", audio_codec="aac")
|
210 |
|
211 |
+
# Clean up temporary files
|
212 |
+
self.cleanup_temp_files()
|
213 |
+
|
214 |
+
def cleanup_temp_files(self):
|
215 |
+
temp_files = ["audio.wav", "t.txt", "transcript.srt","translated_audio.wav","translated_file.srt"] + [f"translated_audio_{i}.wav" for i in range(1, 100)] # Adjust the range accordingly
|
216 |
+
for file in temp_files:
|
217 |
+
if os.path.exists(file):
|
218 |
+
os.remove(file)
|
219 |
+
print(f"Deleted {file}")
|