Skip to content

Commit

Permalink
Auto YAPF with Google python style
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Mar 26, 2024
1 parent 223c23a commit 8bbb4fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions stream_translator_gpt/audio_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ def _open_stream(url: str, format: str, cookies: str):

class StreamAudioGetter(LoopWorkerBase):

def __init__(self, url: str, format: str, cookies: str,
frame_duration: float) -> None:
def __init__(self, url: str, format: str, cookies: str, frame_duration: float) -> None:
self._cleanup_ytdlp_cache()

print('Opening stream: {}'.format(url))
self.ffmpeg_process, self.ytdlp_process = _open_stream(url, format, cookies)
self.byte_size = round(frame_duration * SAMPLE_RATE *
2) # Factor 2 comes from reading the int16 stream as bytes
signal.signal(signal.SIGINT, self._exit_handler)

def __del__(self):
self._cleanup_ytdlp_cache()

Expand All @@ -64,7 +63,7 @@ def _exit_handler(self, signum, frame):
if self.ytdlp_process:
self.ytdlp_process.kill()
sys.exit(0)

def _cleanup_ytdlp_cache(self):
for file in os.listdir('./'):
if file.startswith('--Frag'):
Expand Down
2 changes: 1 addition & 1 deletion stream_translator_gpt/audio_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class RemoteOpenaiWhisper(OpenaiWhisper):
def __init__(self, language: str) -> None:
self.client = OpenAI()
self.language = language

def __del__(self):
if os.path.exists(TEMP_AUDIO_FILE_NAME):
os.remove(TEMP_AUDIO_FILE_NAME)
Expand Down
14 changes: 7 additions & 7 deletions stream_translator_gpt/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def _start_daemon_thread(func, *args, **kwargs):
thread.start()


def main(url, format, cookies, device_index, frame_duration,
continuous_no_speech_threshold, min_audio_length, max_audio_length,
prefix_retention_length, vad_threshold, model, language, use_faster_whisper,
use_whisper_api, whisper_filters, openai_api_key, google_api_key, gpt_translation_prompt,
gpt_translation_history_size, gpt_model, gpt_translation_timeout, gpt_base_url,
retry_if_translation_fails, output_timestamps, hide_transcribe_result, output_file_path,
cqhttp_url, cqhttp_token, discord_webhook_url, **transcribe_options):
def main(url, format, cookies, device_index, frame_duration, continuous_no_speech_threshold,
min_audio_length, max_audio_length, prefix_retention_length, vad_threshold, model,
language, use_faster_whisper, use_whisper_api, whisper_filters, openai_api_key,
google_api_key, gpt_translation_prompt, gpt_translation_history_size, gpt_model,
gpt_translation_timeout, gpt_base_url, retry_if_translation_fails, output_timestamps,
hide_transcribe_result, output_file_path, cqhttp_url, cqhttp_token, discord_webhook_url,
**transcribe_options):

if openai_api_key:
os.environ['OPENAI_API_KEY'] = openai_api_key
Expand Down

0 comments on commit 8bbb4fe

Please sign in to comment.