SPACERUNNER99 commited on
Commit
f1fd455
·
verified ·
1 Parent(s): b4f5804

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
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" Please ignore all previous instructions. Please respond only in the Persian language and keep the srt format. Do not explain what you are doing. Do not self reference. You are an expert translator that will be tasked with translating and improving the spelling/grammar/literary quality of a piece of text. You have a Serious tone of voice. You have a Poetic writing style. Please rewrite the translated text in your tone of voice and writing style. Ensure that the meaning of the original text is not changed. Present the results as follows: Simplified text translation and expert translation. Please execute the command for the following text: {text}"
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, 24, 'arial.ttf', 'yellow', 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')
 
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')