qqwjq1981 commited on
Commit
dc0837c
·
verified ·
1 Parent(s): e84d196

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -40,6 +40,15 @@ def silence(duration, fps=44100):
40
  Returns a silent AudioClip of the specified duration.
41
  """
42
  return AudioArrayClip(np.zeros((int(fps*duration), 2)), fps=fps)
 
 
 
 
 
 
 
 
 
43
 
44
  # Define the passcode
45
  PASSCODE = "show_feedback_db"
@@ -78,7 +87,6 @@ css = """
78
  }
79
  """
80
 
81
-
82
  # Function to save feedback or provide access to the database file
83
  def handle_feedback(feedback):
84
  feedback = feedback.strip() # Clean up leading/trailing whitespace
@@ -123,15 +131,14 @@ def transcribe_video(video_path):
123
  start = segment["start"]
124
  end = segment["end"]
125
  text = segment["text"]
126
- # Count words in the segment
127
- word_count = len(re.findall(r'\w+', text))
128
  transcript_with_timestamps.append({
129
  "start": start,
130
  "end": end,
131
- "text": text,
132
- "word_count": word_count
133
  })
134
-
 
135
  total_words += word_count
136
  total_duration += (end - start)
137
 
 
40
  Returns a silent AudioClip of the specified duration.
41
  """
42
  return AudioArrayClip(np.zeros((int(fps*duration), 2)), fps=fps)
43
+
44
+ def count_words_or_characters(text):
45
+ # Count non-Chinese words
46
+ non_chinese_words = len(re.findall(r'\b[a-zA-Z0-9]+\b', text))
47
+
48
+ # Count Chinese characters
49
+ chinese_chars = len(re.findall(r'[\u4e00-\u9fff]', text))
50
+
51
+ return non_chinese_words + chinese_chars
52
 
53
  # Define the passcode
54
  PASSCODE = "show_feedback_db"
 
87
  }
88
  """
89
 
 
90
  # Function to save feedback or provide access to the database file
91
  def handle_feedback(feedback):
92
  feedback = feedback.strip() # Clean up leading/trailing whitespace
 
131
  start = segment["start"]
132
  end = segment["end"]
133
  text = segment["text"]
134
+
 
135
  transcript_with_timestamps.append({
136
  "start": start,
137
  "end": end,
138
+ "text": text
 
139
  })
140
+
141
+ word_count = count_words_or_characters(text)
142
  total_words += word_count
143
  total_duration += (end - start)
144