Skip to content

Commit fb07846

Browse files
committed
small fixes for webUi translator
1 parent 45077be commit fb07846

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
venv/
2-
.env/
2+
.env/
3+
OpenTranslator/__pycache__/__init__.cpython-310.pyc
4+
OpenTranslator/__pycache__/translator.cpython-310.pyc

OpenTranslator/translator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ def process_audio_chunk(self, input_path, target_language, chunk_idx, output_pat
147147
self.generate_audio(translated_text, Translation_chunk_output_path, target_language, input_path)
148148

149149
return translated_text
150-
self.unload_whisper_model()
151-
152150
except Exception as e:
153151
logging.error(f"Error processing audio: {e}")
154152
return "An Error occurred!", None
153+
finally:
154+
self.unload_whisper_model()
155155

156156
def validate_translation(self, source_text, target_language):
157157
print('validate_translation started ..')
@@ -174,7 +174,7 @@ def validate_translation(self, source_text, target_language):
174174
target_language = code_to_language.get(target_language, "Unknown language")
175175

176176
#supports 10 languages: English, German, French, Spanish, Chinese, Portuguese, Italian, Russian, Korean, and Dutch
177-
pipe = pipeline("text-generation", model="Unbabel/TowerInstruct-7B-v0.2", torch_dtype=torch.bfloat16, device_map=device)
177+
pipe = pipeline("text-generation", model="Unbabel/TowerInstruct-7B-v0.2", torch_dtype=torch.bfloat16, device=device)
178178
# We use the tokenizer’s chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
179179
messages = [
180180
{
Binary file not shown.

0 commit comments

Comments
 (0)