implement basic support for auracast over the network

This commit is contained in:
pstruebi
2025-07-22 16:38:43 +02:00
parent c2901849ff
commit fc8341137a
3 changed files with 13 additions and 15 deletions

View File

@@ -37,7 +37,7 @@ except Exception:
st.title("🎙️ Auracast Audio Mode Control")
# Audio mode selection with persisted default
options = ["Webapp", "USB", "Demo"]
options = ["Webapp", "USB/Network", "Demo"]
saved_audio_mode = saved_settings.get("audio_mode", "Webapp")
if saved_audio_mode not in options:
saved_audio_mode = "Webapp"
@@ -46,7 +46,7 @@ audio_mode = st.selectbox(
"Audio Mode",
options,
index=options.index(saved_audio_mode),
help="Select the audio input source. Choose 'Webapp' for browser microphone, 'USB' for a connected hardware device, or 'Demo' for a simulated stream."
help="Select the audio input source. Choose 'Webapp' for browser microphone, 'USB/Network' for a connected hardware device, or 'Demo' for a simulated stream."
)
if audio_mode == "Demo":
@@ -201,15 +201,9 @@ else:
mic_gain = 1.0
# Input device selection for USB mode
if audio_mode == "USB":
try:
resp = requests.get(f"{BACKEND_URL}/audio_inputs")
if resp.status_code == 200:
input_options = [f"{d['id']}:{d['name']}" for d in resp.json().get('inputs', [])]
else:
input_options = []
except Exception:
input_options = []
if audio_mode == "USB/Network":
resp = requests.get(f"{BACKEND_URL}/audio_inputs")
input_options = [f"{d['id']}:{d['name']}" for d in resp.json().get('inputs', [])]
if not input_options:
st.warning("No hardware audio input devices found. Plug in a USB input device and click Refresh.")
@@ -295,11 +289,11 @@ else:
program_info=program_info,
language=language,
audio_source=(
f"device:{input_device}" if audio_mode == "USB" else (
f"device:{input_device}" if audio_mode == "USB/Network" else (
"webrtc" if audio_mode == "Webapp" else "network"
)
),
input_format=(f"int16le,{q['rate']},1" if audio_mode == "USB" else "auto"),
input_format=(f"int16le,{q['rate']},1" if audio_mode == "USB/Network" else "auto"),
iso_que_len=1, # TODO: this should be way less to decrease delay
sampling_frequency=q['rate'],
octets_per_frame=q['octets'],