Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option to specify different API for translation #893

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ endif

clean:
ifeq ($(OS), Windows_NT)
del /f buzz\$(LIBWHISPER) 2> nul
del /f buzz\whisper_cpp.py 2> nul
rmdir /s /q whisper.cpp\build 2> nul
rmdir /s /q dist 2> nul
-del /f buzz\$(LIBWHISPER) 2> nul
-del /f buzz\whisper_cpp.py 2> nul
-rmdir /s /q whisper.cpp\build 2> nul
-rmdir /s /q dist 2> nul
-rm -f buzz/$(LIBWHISPER)
-rm -f buzz/whisper_cpp.py
-rm -rf whisper.cpp/build || true
-rm -rf dist/* || true
else
rm -f buzz/$(LIBWHISPER)
rm -f buzz/whisper_cpp.py
Expand Down
13 changes: 10 additions & 3 deletions buzz/translator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import logging
import queue

Expand Down Expand Up @@ -35,10 +36,16 @@ def __init__(
self.queue = queue.Queue()

settings = Settings()
custom_openai_base_url = settings.value(
key=Settings.Key.CUSTOM_OPENAI_BASE_URL, default_value=""
custom_openai_base_url = os.getenv(
"BUZZ_TRANSLATION_API_BASE_URl",
settings.value(
key=Settings.Key.CUSTOM_OPENAI_BASE_URL, default_value=""
)
)
openai_api_key = os.getenv(
"BUZZ_TRANSLATION_API_KEY",
get_password(Key.OPENAI_API_KEY)
)
openai_api_key = get_password(Key.OPENAI_API_KEY)
self.openai_client = OpenAI(
api_key=openai_api_key,
base_url=custom_openai_base_url if custom_openai_base_url else None
Expand Down
6 changes: 5 additions & 1 deletion docs/docs/preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ set SOME_OTHER_VARIABLE=some_other_value

On a laptop with 16 threads setting `BUZZ_WHISPERCPP_N_THREADS=8` leads to some 15% speedup in transcription time.
Increasing number of threads even more will lead in slower transcription time as results from parallel threads has to be
combined to produce the final answer.
combined to produce the final answer.

**BUZZ_TRANSLATION_API_BASE_URl** - Base URL of OpenAI compatible API to use for translation. Available from `v1.0.2`.

**BUZZ_TRANSLATION_API_KEY** - Api key of OpenAI compatible API to use for translation. Available from `v1.0.2`.
Loading