Skip to content

Commit

Permalink
fix build for deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienDeepgram committed Jul 13, 2024
1 parent 33df00d commit c6b2d04
Showing 1 changed file with 46 additions and 30 deletions.
76 changes: 46 additions & 30 deletions src/transcription/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,39 +91,55 @@ pub struct Metadata {
model_uuid: String,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TranscriptResponse {
#[serde(rename = "type")]
r#type: String,
start: f64,
duration: f64,
is_final: bool,
speech_final: bool,
from_finalize: bool,
channel: Channel,
metadata: Metadata,
channel_index: Vec<i32>,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UtteranceEndResponse {
#[serde(rename = "type")]
r#type: String,
channel: Vec<u8>,
last_word_end: f64,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SpeechStartedResponse {
#[serde(rename = "type")]
r#type: String,
channel: Vec<u8>,
timestamp: f64,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TerminalResponse {
request_id: String,
created: String,
duration: f64,
channels: u32,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StreamResponse {
TranscriptResponse {
#[serde(rename = "type")]
r#type: String,
start: f64,
duration: f64,
is_final: bool,
speech_final: bool,
from_finalize: bool,
channel: Channel,
metadata: Metadata,
channel_index: Vec<i32>,
},
UtteranceEndResponse {
#[serde(rename = "type")]
r#type: String,
channel: Vec<u8>,
last_word_end: f64,
},
SpeechStartedResponse {
#[serde(rename = "type")]
r#type: String,
channel: Vec<u8>,
timestamp: f64,
},
TerminalResponse {
request_id: String,
created: String,
duration: f64,
channels: u32,
},
Transcript(TranscriptResponse),
UtteranceEnd(UtteranceEndResponse),
SpeechStarted(SpeechStartedResponse),
Terminal(TerminalResponse),
}

#[pin_project]
Expand Down

0 comments on commit c6b2d04

Please sign in to comment.