Fix minor compilation errors
This commit is contained in:
parent
33b7959fab
commit
7cec37044c
|
@ -26,4 +26,4 @@ gst::plugin_define!(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
env!("CARGO_PKG_REPOSITORY"),
|
env!("CARGO_PKG_REPOSITORY"),
|
||||||
env!("BUILD_REL_DATE")
|
env!("BUILD_REL_DATE")
|
||||||
);
|
);
|
||||||
|
|
|
@ -399,7 +399,7 @@ impl Transcriber {
|
||||||
|
|
||||||
let transcript: Transcript = match serde_json::from_str(&payload) {
|
let transcript: Transcript = match serde_json::from_str(&payload) {
|
||||||
Ok(transcript) => transcript,
|
Ok(transcript) => transcript,
|
||||||
Err(err) => {
|
Err(_) => {
|
||||||
// The payload is still not a final transcript, so we just ignore it
|
// The payload is still not a final transcript, so we just ignore it
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -750,11 +750,6 @@ impl Transcriber {
|
||||||
drop(settings);
|
drop(settings);
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
// Set up the server to handle the incoming audio sample rate
|
|
||||||
let in_caps = self.sinkpad.current_caps().unwrap();
|
|
||||||
let s = in_caps.structure(0).unwrap();
|
|
||||||
let sample_rate = s.get::<i32>("rate").unwrap();
|
|
||||||
|
|
||||||
let (ws, _) = {
|
let (ws, _) = {
|
||||||
let _enter = RUNTIME.enter();
|
let _enter = RUNTIME.enter();
|
||||||
futures::executor::block_on(connect_async(url)).map_err(|err| {
|
futures::executor::block_on(connect_async(url)).map_err(|err| {
|
||||||
|
@ -763,24 +758,38 @@ impl Transcriber {
|
||||||
})?
|
})?
|
||||||
};
|
};
|
||||||
|
|
||||||
let (mut ws_sink, mut ws_stream) = ws.split();
|
let (ws_sink, mut ws_stream) = ws.split();
|
||||||
|
|
||||||
let config = Configuration::new(sample_rate);
|
|
||||||
let packet = serde_json::to_vec(&config).unwrap();
|
|
||||||
ws_sink.send(Message::Binary(packet)).await.map_err(|err| {
|
|
||||||
gst_error!(
|
|
||||||
CAT,
|
|
||||||
obj: element,
|
|
||||||
"Failed to configure Vosk server for the expected sample rate: {}",
|
|
||||||
err
|
|
||||||
);
|
|
||||||
gst::FlowError::Error
|
|
||||||
})?;
|
|
||||||
|
|
||||||
*self.ws_sink.borrow_mut() = Some(Box::pin(ws_sink));
|
*self.ws_sink.borrow_mut() = Some(Box::pin(ws_sink));
|
||||||
|
|
||||||
let element_weak = element.downgrade();
|
let element_weak = element.downgrade();
|
||||||
let recv_handle = async move {
|
let recv_handle = async move {
|
||||||
|
// First, send configuration to the Vosk server
|
||||||
|
if let Some(element) = element_weak.upgrade() {
|
||||||
|
let transcribe = element.imp();
|
||||||
|
let mut sender = transcribe.state.lock().unwrap().sender.clone();
|
||||||
|
|
||||||
|
// Set up the server to handle the incoming audio sample rate
|
||||||
|
let in_caps = transcribe.sinkpad.current_caps().unwrap();
|
||||||
|
let s = in_caps.structure(0).unwrap();
|
||||||
|
let sample_rate = s.get::<i32>("rate").unwrap();
|
||||||
|
|
||||||
|
let config = Configuration::new(sample_rate);
|
||||||
|
let packet = serde_json::to_vec(&config).unwrap();
|
||||||
|
let msg = Message::Binary(packet);
|
||||||
|
|
||||||
|
if let Some(sender) = sender.as_mut() {
|
||||||
|
if sender.send(msg).await.is_err() {
|
||||||
|
gst_error!(
|
||||||
|
CAT,
|
||||||
|
obj: &element,
|
||||||
|
"Failed to configure Vosk server for the expected sample rate",
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while let Some(element) = element_weak.upgrade() {
|
while let Some(element) = element_weak.upgrade() {
|
||||||
let transcribe = element.imp();
|
let transcribe = element.imp();
|
||||||
|
|
|
@ -25,4 +25,4 @@ pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
||||||
gst::Rank::None,
|
gst::Rank::None,
|
||||||
Transcriber::static_type(),
|
Transcriber::static_type(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,4 +32,4 @@ pub struct WordInfo {
|
||||||
pub word: String,
|
pub word: String,
|
||||||
pub start: f64,
|
pub start: f64,
|
||||||
pub end: f64,
|
pub end: f64,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue