2020-11-14 17:24:01 +00:00
|
|
|
// Copyright (C) 2020 Mathieu Duponchelle <mathieu@centricular.com>
|
|
|
|
//
|
2022-01-15 18:40:12 +00:00
|
|
|
// 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/>.
|
2020-11-14 17:24:01 +00:00
|
|
|
//
|
2022-01-15 18:40:12 +00:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
2020-11-14 17:24:01 +00:00
|
|
|
|
2021-06-03 18:20:54 +00:00
|
|
|
use gst::glib;
|
|
|
|
use gst::prelude::*;
|
2020-11-14 17:24:01 +00:00
|
|
|
|
|
|
|
mod imp;
|
2023-03-10 13:47:38 +00:00
|
|
|
mod transcribe;
|
|
|
|
mod translate;
|
|
|
|
|
2023-07-06 13:43:37 +00:00
|
|
|
use gst::glib::once_cell::sync::Lazy;
|
2023-03-10 13:47:38 +00:00
|
|
|
|
|
|
|
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
|
|
|
gst::DebugCategory::new(
|
|
|
|
"awstranscribe",
|
|
|
|
gst::DebugColorFlags::empty(),
|
|
|
|
Some("AWS Transcribe element"),
|
|
|
|
)
|
|
|
|
});
|
2023-02-24 20:40:54 +00:00
|
|
|
|
2023-03-31 08:43:36 +00:00
|
|
|
use aws_sdk_transcribestreaming::types::{PartialResultsStability, VocabularyFilterMethod};
|
2020-11-14 17:24:01 +00:00
|
|
|
|
2021-11-22 09:04:26 +00:00
|
|
|
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
|
2021-06-19 01:27:42 +00:00
|
|
|
#[repr(u32)]
|
2021-11-22 09:04:26 +00:00
|
|
|
#[enum_type(name = "GstAwsTranscriberResultStability")]
|
2022-02-06 14:11:12 +00:00
|
|
|
#[non_exhaustive]
|
2021-06-19 01:27:42 +00:00
|
|
|
pub enum AwsTranscriberResultStability {
|
2021-11-22 09:04:26 +00:00
|
|
|
#[enum_value(name = "High: stabilize results as fast as possible", nick = "high")]
|
2021-06-19 01:27:42 +00:00
|
|
|
High = 0,
|
2021-11-22 09:04:26 +00:00
|
|
|
#[enum_value(
|
2021-06-19 01:27:42 +00:00
|
|
|
name = "Medium: balance between stability and accuracy",
|
|
|
|
nick = "medium"
|
|
|
|
)]
|
|
|
|
Medium = 1,
|
2021-11-22 09:04:26 +00:00
|
|
|
#[enum_value(
|
2021-06-19 01:27:42 +00:00
|
|
|
name = "Low: relatively less stable partial transcription results with higher accuracy",
|
|
|
|
nick = "low"
|
|
|
|
)]
|
|
|
|
Low = 2,
|
|
|
|
}
|
|
|
|
|
2023-02-24 20:40:54 +00:00
|
|
|
impl From<AwsTranscriberResultStability> for PartialResultsStability {
|
|
|
|
fn from(val: AwsTranscriberResultStability) -> Self {
|
|
|
|
use AwsTranscriberResultStability::*;
|
|
|
|
match val {
|
|
|
|
High => PartialResultsStability::High,
|
|
|
|
Medium => PartialResultsStability::Medium,
|
|
|
|
Low => PartialResultsStability::Low,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-03 22:42:50 +00:00
|
|
|
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
|
|
|
|
#[repr(u32)]
|
|
|
|
#[enum_type(name = "GstAwsTranscriberVocabularyFilterMethod")]
|
|
|
|
#[non_exhaustive]
|
|
|
|
pub enum AwsTranscriberVocabularyFilterMethod {
|
|
|
|
#[enum_value(name = "Mask: replace words with ***", nick = "mask")]
|
|
|
|
Mask = 0,
|
|
|
|
#[enum_value(name = "Remove: delete words", nick = "remove")]
|
|
|
|
Remove = 1,
|
|
|
|
#[enum_value(name = "Tag: flag words without changing them", nick = "tag")]
|
|
|
|
Tag = 2,
|
|
|
|
}
|
|
|
|
|
2023-02-24 20:40:54 +00:00
|
|
|
impl From<AwsTranscriberVocabularyFilterMethod> for VocabularyFilterMethod {
|
|
|
|
fn from(val: AwsTranscriberVocabularyFilterMethod) -> Self {
|
|
|
|
use AwsTranscriberVocabularyFilterMethod::*;
|
|
|
|
match val {
|
|
|
|
Mask => VocabularyFilterMethod::Mask,
|
|
|
|
Remove => VocabularyFilterMethod::Remove,
|
|
|
|
Tag => VocabularyFilterMethod::Tag,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-11 15:27:51 +00:00
|
|
|
#[derive(Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
|
|
|
|
#[repr(u32)]
|
|
|
|
#[enum_type(name = "GstAwsTranscriberTranslationTokenizationMethod")]
|
|
|
|
#[non_exhaustive]
|
|
|
|
pub enum TranslationTokenizationMethod {
|
|
|
|
#[default]
|
|
|
|
#[enum_value(name = "None: don't tokenize translations", nick = "none")]
|
|
|
|
None = 0,
|
|
|
|
#[enum_value(
|
|
|
|
name = "Span based: insert spans in the transript text and use the resulting spans in the translations to reproduce speech pacing.",
|
|
|
|
nick = "span-based"
|
|
|
|
)]
|
|
|
|
SpanBased = 1,
|
|
|
|
}
|
|
|
|
|
2020-12-17 22:44:49 +00:00
|
|
|
glib::wrapper! {
|
2023-03-10 13:47:38 +00:00
|
|
|
pub struct Transcriber(ObjectSubclass<imp::Transcriber>) @extends gst::Element, gst::Object, @implements gst::ChildProxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
glib::wrapper! {
|
2023-03-15 13:59:50 +00:00
|
|
|
pub struct TranslateSrcPad(ObjectSubclass<imp::TranslateSrcPad>) @extends gst::Pad, gst::Object;
|
2020-11-14 17:24:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
2022-08-25 22:30:08 +00:00
|
|
|
#[cfg(feature = "doc")]
|
|
|
|
{
|
|
|
|
AwsTranscriberResultStability::static_type()
|
|
|
|
.mark_as_plugin_api(gst::PluginAPIFlags::empty());
|
|
|
|
AwsTranscriberVocabularyFilterMethod::static_type()
|
|
|
|
.mark_as_plugin_api(gst::PluginAPIFlags::empty());
|
2023-03-11 15:27:51 +00:00
|
|
|
TranslationTokenizationMethod::static_type()
|
|
|
|
.mark_as_plugin_api(gst::PluginAPIFlags::empty());
|
2023-03-15 13:59:50 +00:00
|
|
|
TranslateSrcPad::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
|
2022-08-25 22:30:08 +00:00
|
|
|
}
|
2020-11-14 17:24:01 +00:00
|
|
|
gst::Element::register(
|
|
|
|
Some(plugin),
|
|
|
|
"awstranscriber",
|
2023-11-02 12:10:59 +00:00
|
|
|
gst::Rank::NONE,
|
2020-11-14 17:24:01 +00:00
|
|
|
Transcriber::static_type(),
|
|
|
|
)
|
|
|
|
}
|