sreepathi-ravikumar commited on
Commit
cd69a04
·
verified ·
1 Parent(s): c9d8970

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -26,27 +26,29 @@ def extract_english_paragraphs(text):
26
  Extract paragraphs that contain only English text
27
  """
28
  paragraphs = text.split('\n\n')
29
- english_paragraphs = []
30
 
31
- for para in paragraphs:
32
  # Check if the paragraph contains only English characters
33
- if not re.search(r'[^\x00-\x7F]', para):
34
- english_paragraphs.append(para.strip())
35
 
36
  return '\n\n'.join(english_paragraphs)
37
 
38
  def extract_native_text(text):
39
- pattern = r'[^\x00-\x7F]'
 
 
40
 
41
  # Search for the first non-English character
42
- match = re.search(pattern, text)
43
 
44
- if match:
45
  # Return everything from the first non-English character
46
- return text[match.start():]
47
- else:
48
  # If no non-English characters found, return empty string
49
- return ""
50
 
51
 
52
  @app.route("/")
@@ -61,8 +63,8 @@ def generate_video():
61
  data = request.get_json()
62
  userprompt = data.get("duration", '').strip
63
  seplines=userprompt.split('\n\n')
64
- prompt=seplines[0] #extract_english_paragraphs(userprompt)
65
- lang=seplines[1] #extract_native_text(userprompt)
66
  prompts=prompt.replace("**","")
67
  print(prompts)
68
  if prompts == '':
 
26
  Extract paragraphs that contain only English text
27
  """
28
  paragraphs = text.split('\n\n')
29
+ english_paragraphs = [paragraphs[0]]
30
 
31
+ #for para in paragraphs:
32
  # Check if the paragraph contains only English characters
33
+ #if not re.search(r'[^\x00-\x7F]', para):
34
+ #english_paragraphs.append(para.strip())
35
 
36
  return '\n\n'.join(english_paragraphs)
37
 
38
  def extract_native_text(text):
39
+ paragraphs = text.split('\n\n')
40
+ nativelang_paragraphs = paragraphs[1]
41
+ #pattern = r'[^\x00-\x7F]'
42
 
43
  # Search for the first non-English character
44
+ #match = re.search(pattern, text)
45
 
46
+ #if match:
47
  # Return everything from the first non-English character
48
+ #return text[match.start():]
49
+ #else:
50
  # If no non-English characters found, return empty string
51
+ return nativelang_paragraphs
52
 
53
 
54
  @app.route("/")
 
63
  data = request.get_json()
64
  userprompt = data.get("duration", '').strip
65
  seplines=userprompt.split('\n\n')
66
+ prompt=extract_english_paragraphs(userprompt)
67
+ lang=extract_native_text(userprompt)
68
  prompts=prompt.replace("**","")
69
  print(prompts)
70
  if prompts == '':