1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Copyright (C) 2020 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;
mod transcribe;
mod translate;
use once_cell::sync::Lazy;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"awstranscribe",
gst::DebugColorFlags::empty(),
Some("AWS Transcribe element"),
)
});
use aws_sdk_transcribestreaming::model::{PartialResultsStability, VocabularyFilterMethod};
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
#[repr(u32)]
#[enum_type(name = "GstAwsTranscriberResultStability")]
#[non_exhaustive]
pub enum AwsTranscriberResultStability {
#[enum_value(name = "High: stabilize results as fast as possible", nick = "high")]
High = 0,
#[enum_value(
name = "Medium: balance between stability and accuracy",
nick = "medium"
)]
Medium = 1,
#[enum_value(
name = "Low: relatively less stable partial transcription results with higher accuracy",
nick = "low"
)]
Low = 2,
}
impl From<AwsTranscriberResultStability> for PartialResultsStability {
fn from(val: AwsTranscriberResultStability) -> Self {
use AwsTranscriberResultStability::*;
match val {
High => PartialResultsStability::High,
Medium => PartialResultsStability::Medium,
Low => PartialResultsStability::Low,
}
}
}
#[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,
}
impl From<AwsTranscriberVocabularyFilterMethod> for VocabularyFilterMethod {
fn from(val: AwsTranscriberVocabularyFilterMethod) -> Self {
use AwsTranscriberVocabularyFilterMethod::*;
match val {
Mask => VocabularyFilterMethod::Mask,
Remove => VocabularyFilterMethod::Remove,
Tag => VocabularyFilterMethod::Tag,
}
}
}
#[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,
}
glib::wrapper! {
pub struct Transcriber(ObjectSubclass<imp::Transcriber>) @extends gst::Element, gst::Object, @implements gst::ChildProxy;
}
glib::wrapper! {
pub struct TranslationSrcPad(ObjectSubclass<imp::TranslationSrcPad>) @extends gst::Pad, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
#[cfg(feature = "doc")]
{
AwsTranscriberResultStability::static_type()
.mark_as_plugin_api(gst::PluginAPIFlags::empty());
AwsTranscriberVocabularyFilterMethod::static_type()
.mark_as_plugin_api(gst::PluginAPIFlags::empty());
TranslationTokenizationMethod::static_type()
.mark_as_plugin_api(gst::PluginAPIFlags::empty());
TranslationSrcPad::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
}
gst::Element::register(
Some(plugin),
"awstranscriber",
gst::Rank::None,
Transcriber::static_type(),
)
}
|