Update app.py
Browse files
app.py
CHANGED
@@ -287,7 +287,7 @@ def enhance_text(api_key, text, google):
|
|
287 |
# Prepare the request body
|
288 |
request_body = [{
|
289 |
"role": "user",
|
290 |
-
"content": f"
|
291 |
},]
|
292 |
|
293 |
# Add the API key to the request
|
@@ -378,7 +378,7 @@ def process_video(url, type):
|
|
378 |
print(video)
|
379 |
subtitles = pysrt.open("google_translate.srt", encoding="utf-8")
|
380 |
output_video_file = input_video_name + '_subtitled' + ".mp4"
|
381 |
-
subtitle_clips = create_subtitle_clips(subtitles, video.size,
|
382 |
final_video = CompositeVideoClip([video] + subtitle_clips)
|
383 |
final_video.write_videofile(output_video_file, codec="libx264", audio_codec="aac", logger=None)
|
384 |
print('final')
|
|
|
287 |
# Prepare the request body
|
288 |
request_body = [{
|
289 |
"role": "user",
|
290 |
+
"content": f"I have a video transcription in English that needs to be translated into Persian. The subject of the video is philosophy and life advice. The translation should have a poetic and literary tone, but it must also stay faithful to the original meaning without introducing unnecessary changes or overcomplications.Please follow these guidelines:Preserve the exact meaning of each sentence while adding a touch of Persian literary elegance.Keep the language clear and accessible, avoiding over-complicated or embellished phrases that alter the message.Ensure proper Persian grammar and structure for a polished, fluent result.Maintain alignment with the time ranges provided for subtitles.When in doubt, prioritize clarity and fidelity to the original text over poetic embellishments.Here is the transcription:{text} . in respose dont add any thing exept for the srt formated translation."
|
291 |
},]
|
292 |
|
293 |
# Add the API key to the request
|
|
|
378 |
print(video)
|
379 |
subtitles = pysrt.open("google_translate.srt", encoding="utf-8")
|
380 |
output_video_file = input_video_name + '_subtitled' + ".mp4"
|
381 |
+
subtitle_clips = create_subtitle_clips(subtitles, video.size, 32, 'arial.ttf', 'white', False)
|
382 |
final_video = CompositeVideoClip([video] + subtitle_clips)
|
383 |
final_video.write_videofile(output_video_file, codec="libx264", audio_codec="aac", logger=None)
|
384 |
print('final')
|