Works for transcribing audio, needs tunning
This commit is contained in:
parent
f463d0f68c
commit
36b6f8e70d
1 changed files with 24 additions and 29 deletions
|
@ -654,8 +654,9 @@ impl Transcriber {
|
||||||
|
|
||||||
gst_trace!(CAT, obj: element, "Sending {} bytes", data.len());
|
gst_trace!(CAT, obj: element, "Sending {} bytes", data.len());
|
||||||
|
|
||||||
|
for chunk in data.chunks(8_000) {
|
||||||
ws_sink
|
ws_sink
|
||||||
.send(Message::Binary(data.to_vec()))
|
.send(Message::Binary(chunk.to_vec()))
|
||||||
.await
|
.await
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
gst_error!(
|
gst_error!(
|
||||||
|
@ -666,6 +667,7 @@ impl Transcriber {
|
||||||
);
|
);
|
||||||
gst::FlowError::Error
|
gst::FlowError::Error
|
||||||
})?;
|
})?;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
gst_info!(
|
gst_info!(
|
||||||
CAT,
|
CAT,
|
||||||
|
@ -767,16 +769,13 @@ impl Transcriber {
|
||||||
})?
|
})?
|
||||||
};
|
};
|
||||||
|
|
||||||
let (ws_sink, mut ws_stream) = ws.split();
|
let (mut ws_sink, mut ws_stream) = ws.split();
|
||||||
|
|
||||||
*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
|
// First, send configuration to the Vosk server
|
||||||
if let Some(element) = element_weak.upgrade() {
|
if let Some(element) = element_weak.upgrade() {
|
||||||
let transcribe = element.imp();
|
let transcribe = element.imp();
|
||||||
let mut sender = transcribe.state.lock().unwrap().sender.clone();
|
|
||||||
|
|
||||||
// Set up the server to handle the incoming audio sample rate
|
// Set up the server to handle the incoming audio sample rate
|
||||||
let in_caps = transcribe.sinkpad.current_caps().unwrap();
|
let in_caps = transcribe.sinkpad.current_caps().unwrap();
|
||||||
|
@ -791,11 +790,8 @@ impl Transcriber {
|
||||||
);
|
);
|
||||||
|
|
||||||
let config = Configuration::new(sample_rate);
|
let config = Configuration::new(sample_rate);
|
||||||
let packet = serde_json::to_vec(&config).unwrap();
|
let packet = serde_json::to_string(&config).unwrap();
|
||||||
let msg = Message::Binary(packet);
|
if ws_sink.send(Message::Text(packet)).await.is_err() {
|
||||||
|
|
||||||
if let Some(sender) = sender.as_mut() {
|
|
||||||
if sender.send(msg).await.is_err() {
|
|
||||||
gst_error!(
|
gst_error!(
|
||||||
CAT,
|
CAT,
|
||||||
obj: &element,
|
obj: &element,
|
||||||
|
@ -804,9 +800,8 @@ impl Transcriber {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return;
|
*transcribe.ws_sink.borrow_mut() = Some(Box::pin(ws_sink));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while let Some(element) = element_weak.upgrade() {
|
while let Some(element) = element_weak.upgrade() {
|
||||||
|
|
Loading…
Reference in a new issue