mirror of
https://github.com/HiMeditator/auto-caption.git
synced 2026-02-13 02:54:48 +08:00
feat(python-subprocess): 尝试字幕显示新解决方案
- 使用 python 子进程解析字幕 - 通过 websocket 通信将字幕传递给软件
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from dashscope.audio.asr import \
|
||||
TranslationRecognizerCallback, \
|
||||
TranscriptionResult, \
|
||||
TranslationResult, \
|
||||
TranslationRecognizerRealtime
|
||||
from dashscope.audio.asr import (
|
||||
TranslationRecognizerCallback,
|
||||
TranscriptionResult,
|
||||
TranslationResult,
|
||||
TranslationRecognizerRealtime
|
||||
)
|
||||
|
||||
class Callback(TranslationRecognizerCallback):
|
||||
"""
|
||||
@@ -53,15 +54,15 @@ class Callback(TranslationRecognizerCallback):
|
||||
if usage: self.usage += usage['duration']
|
||||
|
||||
|
||||
def getGummpyTranslator(rate) -> TranslationRecognizerRealtime:
|
||||
translator = TranslationRecognizerRealtime(
|
||||
class GummyTranslator:
|
||||
def __init__(self, rate, source, target):
|
||||
self.translator = TranslationRecognizerRealtime(
|
||||
model = "gummy-realtime-v1",
|
||||
format = "pcm",
|
||||
sample_rate = rate,
|
||||
transcription_enabled = True,
|
||||
translation_enabled = True,
|
||||
source_language = "ja",
|
||||
translation_target_languages = ["zh"],
|
||||
source_language = source,
|
||||
translation_target_languages = [target],
|
||||
callback = Callback()
|
||||
)
|
||||
return translator
|
||||
)
|
||||
Reference in New Issue
Block a user