net: new deepgram plugin

The plugin only contains a transcriber for now.
This commit is contained in:
Mathieu Duponchelle 2025-08-20 18:54:25 +02:00
parent e92250847d
commit 9de21fc826
9 changed files with 1677 additions and 323 deletions

747
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,7 @@ members = [
"mux/mp4",
"net/aws",
"net/deepgram",
"net/hlsmultivariantsink",
"net/hlssink3",
"net/mpegtslive",

View file

@ -157,6 +157,7 @@ plugins = {
'library': 'libgstaws',
'extra-deps': {'openssl': ['>=1.1']},
},
'deepgram': {'library': 'libgstdeepgram',}
'mpegtslive': {'library': 'libgstmpegtslive'},
'hlsmultivariantsink': {'library': 'libgsthlsmultivariantsink'},
'hlssink3': {'library': 'libgsthlssink3'},

View file

@ -32,6 +32,7 @@ option('mp4', type: 'feature', value: 'auto', description: 'Build mp4 plugin')
# net
option('aws', type: 'feature', value: 'auto', description: 'Build aws plugin')
option('deepgram', type: 'feature', value: 'auto', description: 'Build deepgram plugin')
option('hlsmultivariantsink', type: 'feature', value: 'auto', description: 'Build hlsmultivariantsink plugin')
option('hlssink3', type: 'feature', value: 'auto', description: 'Build hlssink3 plugin')
option('mpegtslive', type: 'feature', value: 'auto', description: 'Build mpegtslive plugin')

47
net/deepgram/Cargo.toml Normal file
View file

@ -0,0 +1,47 @@
[package]
name = "gst-plugin-deepgram"
version.workspace = true
authors = ["Mathieu Duponchelle <mathieu@centricular.com>"]
repository.workspace = true
license = "MPL-2.0"
description = "GStreamer Deepgram plugin"
edition.workspace = true
rust-version.workspace = true
[dependencies]
gst.workspace = true
gst-base.workspace = true
gst-audio = { workspace = true, features = ["v1_16"] }
anyhow = "1"
futures = "0.3"
tokio = { version = "1.0", features = [ "full" ] }
deepgram = "0.7"
async-stream = "0.3"
bytes = "1"
[lib]
name = "gstdeepgram"
crate-type = ["cdylib", "rlib"]
path = "src/lib.rs"
[build-dependencies]
gst-plugin-version-helper.workspace = true
[features]
static = []
capi = []
doc = ["gst/v1_18"]
[package.metadata.capi]
min_version = "0.9.21"
[package.metadata.capi.header]
enabled = false
[package.metadata.capi.library]
install_subdir = "gstreamer-1.0"
versioning = false
import_library = false
[package.metadata.capi.pkg_config]
requires_private = "gstreamer-1.0, gstreamer-base-1.0, gstreamer-audio-1.0, gobject-2.0, glib-2.0, gmodule-2.0, openssl"

3
net/deepgram/build.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
gst_plugin_version_helper::info()
}

36
net/deepgram/src/lib.rs Normal file
View file

@ -0,0 +1,36 @@
// Copyright (C) 2025 Mathieu Duponchelle <mathieu@centricular.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// <https://mozilla.org/MPL/2.0/>.
//
// SPDX-License-Identifier: MPL-2.0
#![allow(clippy::non_send_fields_in_send_ty, unused_doc_comments)]
/**
* plugin-deepgram:
*
* Since: plugins-rs-0.15
*/
use gst::glib;
mod transcriber;
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
transcriber::register(plugin)?;
Ok(())
}
gst::plugin_define!(
deepgram,
env!("CARGO_PKG_DESCRIPTION"),
plugin_init,
concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")),
// FIXME: MPL-2.0 is only allowed since 1.18.3 (as unknown) and 1.20 (as known)
"MPL",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_REPOSITORY"),
env!("BUILD_REL_DATE")
);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,58 @@
// Copyright (C) 2025 Mathieu Duponchelle <mathieu@centricular.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// <https://mozilla.org/MPL/2.0/>.
//
// SPDX-License-Identifier: MPL-2.0
use gst::glib;
use gst::prelude::*;
mod imp;
use std::sync::LazyLock;
static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new(
"deepgramtranscriber",
gst::DebugColorFlags::empty(),
Some("Deepgram transcribe element"),
)
});
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
#[repr(u32)]
#[enum_type(name = "GstDeepgramInterimStrategy")]
#[non_exhaustive]
pub enum DeepgramInterimStrategy {
#[enum_value(name = "Disabled: don't use interim results", nick = "disabled")]
Disabled = 0,
#[enum_value(
name = "Index: track current word in interim results by index",
nick = "index"
)]
Index = 1,
#[enum_value(
name = "Timing: track current word in interim results by timing",
nick = "timing"
)]
Timing = 2,
}
glib::wrapper! {
pub struct Transcriber(ObjectSubclass<imp::Transcriber>) @extends gst::Element, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
#[cfg(feature = "doc")]
{
DeepgramInterimStrategy::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
}
gst::Element::register(
Some(plugin),
"deepgramtranscriber",
gst::Rank::NONE,
Transcriber::static_type(),
)
}