Update modules/translation/translation_base.py
Browse files
modules/translation/translation_base.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
from abc import ABC, abstractmethod
|
@@ -178,9 +179,12 @@ class TranslationBase(ABC):
|
|
178 |
for index, dic in enumerate(input_list_dict):
|
179 |
progress(index / total_progress, desc="Translating..")
|
180 |
translated_text = self.translate(dic["text"], max_length=max_length)
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
184 |
|
185 |
dic["text"] = translated_text
|
186 |
|
|
|
1 |
import os
|
2 |
+
import re
|
3 |
import torch
|
4 |
import gradio as gr
|
5 |
from abc import ABC, abstractmethod
|
|
|
179 |
for index, dic in enumerate(input_list_dict):
|
180 |
progress(index / total_progress, desc="Translating..")
|
181 |
translated_text = self.translate(dic["text"], max_length=max_length)
|
182 |
+
|
183 |
+
# Add speaker ID to translated sentence when diarization is enabled
|
184 |
+
if re.search(': ',dic['text']) != None:
|
185 |
+
speaker_id = ((dic['text']).split(":", 1)[0]).strip()
|
186 |
+
if speaker_id != "":
|
187 |
+
translated_text = speaker_id + ": " + translated_text
|
188 |
|
189 |
dic["text"] = translated_text
|
190 |
|