fix: refresh ASR ingress attributes per session
| | |
| | | .expect("bound json"); |
| | | assert_eq!("controlled_fixture", with_metadata["inputSourceCategory"]); |
| | | assert_eq!("fixture-01", with_metadata["clientFixtureSequence"]); |
| | | let next = AudioIngressMetadata { |
| | | input_source_category: "controlled_fixture".to_string(), |
| | | client_fixture_sequence: "fixture-02".to_string(), |
| | | }; |
| | | let next_line = session_start_line( |
| | | "call-001", |
| | | "trace-001", |
| | | "turn-0002", |
| | | "nonce-001", |
| | | Some(&next), |
| | | ) |
| | | .expect("next bound session line"); |
| | | let next_value: serde_json::Value = serde_json::from_slice(&next_line).expect("next json"); |
| | | assert_eq!("fixture-02", next_value["clientFixtureSequence"]); |
| | | assert_ne!( |
| | | with_metadata["clientFixtureSequence"], |
| | | next_value["clientFixtureSequence"] |
| | | ); |
| | | } |
| | | |
| | | #[test] |
| | |
| | | options::TrackPublishOptions, |
| | | prelude::{ |
| | | DataPacket, LocalAudioTrack, LocalTrack, ParticipantIdentity, RemoteAudioTrack, |
| | | RemoteTrack, Room, RoomEvent, RoomOptions, |
| | | RemoteParticipant, RemoteTrack, Room, RoomEvent, RoomOptions, |
| | | }, |
| | | }; |
| | | use reqwest::Client; |
| | |
| | | "runtime helper ignored non-user audio participant"); |
| | | continue; |
| | | } |
| | | let ingress_metadata = |
| | | match AudioIngressMetadata::from_participant(&participant.attributes()) { |
| | | Ok(value) => value, |
| | | Err(reason) => { |
| | | warn!(call_id = %call_id, trace_id = %trace_id, |
| | | metadata_status = "invalid", reason = reason, |
| | | "runtime helper ignored invalid audio ingress metadata"); |
| | | None |
| | | } |
| | | }; |
| | | let participant_alias = redact(&participant.identity().to_string()); |
| | | let track_sid_alias = redact(&track.sid().to_string()); |
| | | let track_name = track.name(); |
| | |
| | | track_sid_alias = %track_sid_alias, |
| | | track_name = %track_name, |
| | | track_source = %track_source, |
| | | metadata_status = if ingress_metadata.is_some() { "bound" } else { "absent" }, |
| | | metadata_source = ingress_metadata.as_ref().map(|_| "controlled_fixture"), |
| | | metadata_sequence_present = ingress_metadata.is_some(), |
| | | "runtime helper user_track_subscribed" |
| | | ); |
| | | spawn_user_audio_frame_observer( |
| | |
| | | turn_bridge_config.clone(), |
| | | http.clone(), |
| | | sink.clone(), |
| | | participant, |
| | | ); |
| | | } |
| | | RoomEvent::TrackSubscribed { |
| | |
| | | turn_bridge_config: TurnBridgeConfig, |
| | | http: Client, |
| | | sink: Arc<BotAudioOutputSink>, |
| | | participant: RemoteParticipant, |
| | | ) -> JoinHandle<()> { |
| | | tokio::spawn(async move { |
| | | let mut stream = NativeAudioStream::new( |
| | |
| | | |
| | | if !was_in_speech && is_in_speech { |
| | | let turn_id = format!("turn-{:04}", vad.turn_index); |
| | | let ingress_metadata = match AudioIngressMetadata::from_participant( |
| | | &participant.attributes(), |
| | | ) { |
| | | Ok(value) => value, |
| | | Err(reason) => { |
| | | warn!(call_id = %call_id, trace_id = %trace_id, |
| | | turn_id = %turn_id, metadata_status = "invalid", reason = reason, |
| | | "runtime helper ignored invalid audio ingress metadata"); |
| | | None |
| | | } |
| | | }; |
| | | match RealtimeAsrUpload::start( |
| | | http.clone(), |
| | | turn_bridge_config.realtime_asr_config(), |