basic working cloud model
This commit is contained in:
@@ -16,47 +16,39 @@ import voice_models.request_models
|
||||
|
||||
|
||||
def announcement_from_german_text(
|
||||
global_config: auracast_config.AuracastGlobalConfig,
|
||||
translator_config: List[translator_config.TranslatorConfigDe],
|
||||
config: translator_config.TranslatorConfigGroup,
|
||||
text_de
|
||||
):
|
||||
base_lang = "deu"
|
||||
|
||||
audio_data_dict = {}
|
||||
for i, trans in enumerate(translator_config):
|
||||
if trans.big.language == base_lang:
|
||||
for i, big in enumerate(config.bigs):
|
||||
if big.language == base_lang:
|
||||
text = text_de
|
||||
else:
|
||||
text = llm_translator.translate_de_to_x(
|
||||
text_de,
|
||||
trans.big.language,
|
||||
model=trans.translator_llm,
|
||||
client = trans.llm_client,
|
||||
host=trans.llm_host_url,
|
||||
token=trans.llm_host_token
|
||||
big.language,
|
||||
model=big.translator_llm,
|
||||
client = big.llm_client,
|
||||
host=big.llm_host_url,
|
||||
token=big.llm_host_token
|
||||
)
|
||||
|
||||
log.info('%s', text)
|
||||
request_data = voice_models.request_models.SynthesizeRequest(
|
||||
text=text,
|
||||
target_sample_rate=global_config.auracast_sampling_rate_hz,
|
||||
framework=trans.tts_system,
|
||||
model=trans.tts_model,
|
||||
target_sample_rate=config.auracast_sampling_rate_hz,
|
||||
framework=big.tts_system,
|
||||
model=big.tts_model,
|
||||
return_lc3=True
|
||||
)
|
||||
start = time.time()
|
||||
lc3_audio = voice_client.tts_client.request_synthesis(
|
||||
request_data
|
||||
)
|
||||
|
||||
# lc3_audio = text_to_speech.synthesize(
|
||||
# text,
|
||||
# global_config.auracast_sampling_rate_hz,
|
||||
# trans.tts_system,
|
||||
# trans.tts_model,
|
||||
# return_lc3=True
|
||||
# )
|
||||
|
||||
audio_data_dict[trans.big.language] = lc3_audio.decode('latin-1') # TODO: should be .hex in the future
|
||||
log.info('Voice synth took %s', time.time() - start)
|
||||
audio_data_dict[big.language] = lc3_audio.decode('latin-1') # TODO: should be .hex in the future
|
||||
|
||||
multicast_client.send_audio(
|
||||
audio_data_dict
|
||||
@@ -69,27 +61,26 @@ if __name__ == '__main__':
|
||||
format='%(module)s.py:%(lineno)d %(levelname)s: %(message)s'
|
||||
)
|
||||
|
||||
global_conf = auracast_config.AuracastGlobalConfig()
|
||||
#global_conf.transport='serial:/dev/serial/by-id/usb-SEGGER_J-Link_001057705357-if02,1000000,rtscts' # transport for nrf54l15dk
|
||||
global_conf.transport='serial:/dev/serial/by-id/usb-ZEPHYR_Zephyr_HCI_UART_sample_81BD14B8D71B5662-if00,115200,rtscts' #nrf52dongle hci_uart usb cdc
|
||||
|
||||
|
||||
translator_conf = [
|
||||
translator_config.TranslatorConfigDe(),
|
||||
translator_config.TranslatorConfigEn(),
|
||||
translator_config.TranslatorConfigFr(),
|
||||
#auracast_config.broadcast_es,
|
||||
#auracast_config.broadcast_it,
|
||||
config = translator_config.TranslatorConfigGroup(
|
||||
bigs=[
|
||||
translator_config.TranslatorConfigDe(),
|
||||
translator_config.TranslatorConfigEn(),
|
||||
translator_config.TranslatorConfigFr(),
|
||||
]
|
||||
|
||||
for conf in translator_conf:
|
||||
conf.big.loop = False
|
||||
)
|
||||
|
||||
config.transport='serial:/dev/serial/by-id/usb-ZEPHYR_Zephyr_HCI_UART_sample_81BD14B8D71B5662-if00,115200,rtscts' #nrf52dongle hci_uart usb cdc
|
||||
|
||||
for conf in config.bigs:
|
||||
conf.loop = False
|
||||
conf.llm_client = 'openwebui' # comment out for local llm
|
||||
conf.llm_host_url = 'https://ollama.pstruebi.xyz'
|
||||
conf.llm_host_token = 'sk-17124cb84df14cc6ab2d9e17d0724d13'
|
||||
|
||||
multicast_client.request_init(
|
||||
config
|
||||
)
|
||||
|
||||
multicast_client.initialize()
|
||||
|
||||
announcement_from_german_text(global_conf, translator_conf, 'Hello')
|
||||
announcement_from_german_text(config, 'Hello')
|
||||
|
||||
# TODO: make everything async
|
||||
|
||||
@@ -5,7 +5,7 @@ from auracast import auracast_config
|
||||
|
||||
VENV_DIR = os.path.join(os.path.dirname(__file__), './../../venv')
|
||||
|
||||
class TranslatorLangConfig(BaseModel):
|
||||
class TranslatorLangConfig(auracast_config.AuracastBigConfig):
|
||||
translator_llm: str = 'llama3.2:3b-instruct-q4_0'
|
||||
llm_client: str = 'ollama'
|
||||
llm_host_url: str | None = 'http://localhost:11434'
|
||||
|
||||
Reference in New Issue
Block a user