implement support for predefinced announcements
This commit is contained in:
@@ -4,6 +4,7 @@ list prompt example
|
||||
"""
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from dataclasses import asdict
|
||||
import asyncio
|
||||
from copy import copy
|
||||
import time
|
||||
@@ -16,7 +17,8 @@ from text_to_speech import text_to_speech
|
||||
from encode import encode_lc3
|
||||
from auracast import multicast_control
|
||||
from auracast import auracast_config
|
||||
from config import LANG_CONFIG, BITRATE_BPS, SAMPLING_RATE_HZ, FRAME_DUR_MS
|
||||
from config import LANG_CONFIG, SAMPLING_RATE_HZ
|
||||
from translator.test_content import TESTSENTENCE
|
||||
|
||||
# TODO: look for a end to end translation solution
|
||||
|
||||
@@ -63,10 +65,15 @@ async def announcement_from_german_text(caster:multicast_control.Multicaster, te
|
||||
log.info("Starting all broadcasts took %s s", round(time.time() - start, 3))
|
||||
|
||||
|
||||
|
||||
async def command_line_ui(caster: multicast_control.Multicaster):
|
||||
while True:
|
||||
command = await aioconsole.ainput("\nEnter your Announcement|quit] > ")
|
||||
# make a list of all available testsentence
|
||||
sentence_list = list(asdict(TESTSENTENCE).values())
|
||||
|
||||
prompt = "Enter your Announcement|quit or choose:] > \n"
|
||||
prompt += "\n".join([f"{i}: {s}" for i,s in enumerate(sentence_list)])
|
||||
prompt += "\n"
|
||||
command = await aioconsole.ainput(prompt)
|
||||
|
||||
if command.strip().lower() == "quit":
|
||||
print("👋 Exiting...")
|
||||
@@ -74,12 +81,17 @@ async def command_line_ui(caster: multicast_control.Multicaster):
|
||||
caster.stop_streaming()
|
||||
await caster.shutdown()
|
||||
break # Exit loop
|
||||
# TODO: Implement predefined announcements
|
||||
|
||||
elif command.strip() == '':
|
||||
print('Nothing to Announce')
|
||||
# Check if command is a single number
|
||||
elif command.strip().isdigit():
|
||||
ind = int(command.strip())
|
||||
await announcement_from_german_text(caster, sentence_list[ind])
|
||||
await asyncio.wait([caster.streamer.task])
|
||||
# Interpret the command as announcement
|
||||
else:
|
||||
await announcement_from_german_text(caster, command)
|
||||
await asyncio.wait([caster.streamer.task])
|
||||
|
||||
async def main():
|
||||
log.basicConfig(
|
||||
@@ -91,7 +103,7 @@ async def main():
|
||||
#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
|
||||
|
||||
big_conf = [ # TODO: integrate this in the LANG_CONFIG dict, better: make a hirachry of dataclasses
|
||||
big_conf = [
|
||||
auracast_config.broadcast_de,
|
||||
auracast_config.broadcast_en,
|
||||
auracast_config.broadcast_fr,
|
||||
@@ -112,4 +124,8 @@ async def main():
|
||||
#await asyncio.wait([caster.streamer.task])
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
asyncio.run(main())
|
||||
|
||||
# TODO: integrate this in the LANG_CONFIG dict, better: make a hierachy of dataclasses
|
||||
# TODO: remove the nececcity for files
|
||||
# TODO: add support for multiple radios
|
||||
@@ -1,9 +1,11 @@
|
||||
TESTSENTENCE_DE_HELLO = 'Hallo Welt.'
|
||||
TESTSENTENCE_DE_WAVE_PARTICLE = 'Der Wellen-Teilchen-Dualismus beschreibt die Eigenschaft von Teilchen, sowohl als Wellen auf der Mikroebene zu verhalten und gleichzeitig bestimmte Eigenschaften wie Impuls und Energietrang zu besitzen.'
|
||||
TESTSENTENCE_DE_BROKER = 'Ein Broker (oder Makler) ist eine Person oder ein Unternehmen, das sich zwischen dem Kauf- und Verkaufsberechtigten einer Wirtschaftsgüter (z.B. Aktien, Optionen, Derivate, Währungen, Rohstoffe usw.) stellt und als Vermittler fungiert. Sein Hauptziel ist es, Transaktionen zu erleichtern und Geld für sich selbst zu verdienen.'
|
||||
TESTSENTENCE_DE_RAINBOW = 'Der Regenbogen ist ein atmosphärisch-optisches Phänomen, das als kreisbogenförmiges farbiges Lichtband in einer von der Sonne beschienenen Regenwand oder wolke wahrgenommen wird.'
|
||||
TESTSENTENCE_DE_GATE_OPENED = "Please be advised that Gate 23 has opened for boarding."
|
||||
TESTSENTENCE_DE_TRAIN_DELAYS = "Please note that delays have been reported on the InterCity train route. We apologize for any inconvenience this may cause."
|
||||
TESTSENTENCE_DE_LOST_LUGGAGE = "Attention passengers! Lost luggage has been reported at Track 4. If you have not yet received your bag, please report to our lost luggage desk for assistance."
|
||||
TESTSENTENCE_DE_PLANE_TAKEOFF_DELAYED = "This departing flight's departure time has changed due to weather conditions. The new boarding time will be advised shortly."
|
||||
TESTSENTENCE_DE_SECURITY_CHECKPOINT_OPENING = "Security Checkpoint 5 is now open. Please proceed through the checkpoint to minimize your wait time during security screening."
|
||||
from dataclasses import dataclass, fields, asdict
|
||||
|
||||
@dataclass
|
||||
class TestContent:
|
||||
DE_HELLO: str = 'Hallo Welt.'
|
||||
DE_GATE_OPENED: str = "Gate 23 ist jetzt geöffnet."
|
||||
DE_TRAIN_ARRIVING: str = "Der Zug Nach Wien fährt heute von Gleis 3."
|
||||
DE_SECURITY_CHECKPOINT_OPENING: str = "Sicherheitskontrolle 5 ist jetzt geöffnet. Bitte setzen Sie sich in Bewegung, um Ihre Wartezeit während Sicherungsprüfungen zu minimieren."
|
||||
DE_RAINBOW: str = 'Der Regenbogen ist ein atmosphärisch-optisches Phänomen, das als kreisbogenförmiges farbiges Lichtband in einer von der Sonne beschienenen Wolke oder Regenwand wahrgenommen wird und ein großes Farbspektrum anzeigt.'
|
||||
DE_WAVE_PARTICLE: str = 'Der Wellen-Teilchen-Dualismus ist eine Konzeption, die postuliert, dass Teilchen sowohl als Wellen auf der Mikroebene verhalten sich und genau bestimme Eigenschaften wie Impuls und Energietrang besaßen.'
|
||||
TESTSENTENCE = TestContent()
|
||||
|
||||
Reference in New Issue
Block a user