Spaces:
Running
Running
Update generate_transcript.py
Browse files- generate_transcript.py +14 -2
generate_transcript.py
CHANGED
@@ -6,6 +6,12 @@ import warnings
|
|
6 |
from groq import Groq
|
7 |
import os
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
warnings.filterwarnings('ignore')
|
10 |
|
11 |
|
@@ -152,7 +158,13 @@ class TranscriptProcessor:
|
|
152 |
pickle.dump(transcript, f)
|
153 |
|
154 |
return self.transcript_output_path
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
def rewrite_transcript(self):
|
157 |
"""
|
158 |
Refines the transcript for TTS, adding expressive elements and saving as a list of tuples.
|
@@ -178,7 +190,7 @@ class TranscriptProcessor:
|
|
178 |
model=self.model_name,
|
179 |
)
|
180 |
|
181 |
-
rewritten_transcript =
|
182 |
|
183 |
# Save the rewritten transcript as a pickle file
|
184 |
with open(self.tts_output_path, 'wb') as f:
|
|
|
6 |
from groq import Groq
|
7 |
import os
|
8 |
|
9 |
+
|
10 |
+
import re
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
warnings.filterwarnings('ignore')
|
16 |
|
17 |
|
|
|
158 |
pickle.dump(transcript, f)
|
159 |
|
160 |
return self.transcript_output_path
|
161 |
+
|
162 |
+
def extract_tuple(self,text):
|
163 |
+
match = re.search(r'\[.*\]', text)
|
164 |
+
if match:
|
165 |
+
return match.group(0)
|
166 |
+
return None
|
167 |
+
|
168 |
def rewrite_transcript(self):
|
169 |
"""
|
170 |
Refines the transcript for TTS, adding expressive elements and saving as a list of tuples.
|
|
|
190 |
model=self.model_name,
|
191 |
)
|
192 |
|
193 |
+
rewritten_transcript =self.extract_tuple(chat_completion.choices[0].message.content)
|
194 |
|
195 |
# Save the rewritten transcript as a pickle file
|
196 |
with open(self.tts_output_path, 'wb') as f:
|