Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK Update and Refactor #76

Merged
merged 135 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
5b625ff
Add text to speech
DamienDeepgram Jul 13, 2024
87ccf67
Add text to speech
DamienDeepgram Jul 13, 2024
0ae2ec5
fix build errors
DamienDeepgram Jul 13, 2024
7114c84
fix build errors
DamienDeepgram Jul 14, 2024
49304cd
fix build errors
DamienDeepgram Jul 14, 2024
4cc02af
fix build errors
DamienDeepgram Jul 14, 2024
e06c401
fix build errors
DamienDeepgram Jul 14, 2024
4d554c5
remove wav file
DamienDeepgram Jul 14, 2024
6daa8db
Add streaming TTS playback - still has an issue with playback but com…
DamienDeepgram Jul 14, 2024
05f413f
fix the white noise issue
DamienDeepgram Jul 14, 2024
f0d43b1
fix build errors
DamienDeepgram Jul 14, 2024
f4df430
fix build errors
DamienDeepgram Jul 14, 2024
1164439
fix build errors
DamienDeepgram Jul 14, 2024
c314d9b
fix build errors
DamienDeepgram Jul 14, 2024
372ab73
fix build errors
DamienDeepgram Jul 14, 2024
2e6e3c2
fix build errors
DamienDeepgram Jul 14, 2024
f7c9d50
fix build errors
DamienDeepgram Jul 14, 2024
c7be6ff
fix build errors
DamienDeepgram Jul 14, 2024
9d53691
fix build errors
DamienDeepgram Jul 14, 2024
24f7e6d
fix build errors
DamienDeepgram Jul 14, 2024
0db5703
fix build errors
DamienDeepgram Jul 14, 2024
07e8345
fix build errors
DamienDeepgram Jul 14, 2024
52248f7
fix build errors
DamienDeepgram Jul 14, 2024
dd1777d
fix build errors
DamienDeepgram Jul 14, 2024
4440ff0
fix build errors
DamienDeepgram Jul 14, 2024
d012d6c
fix build errors
DamienDeepgram Jul 14, 2024
9bab758
fix build errors
DamienDeepgram Jul 14, 2024
a27de1f
fix build errors
DamienDeepgram Jul 14, 2024
470e4e2
fix build errors
DamienDeepgram Jul 14, 2024
b9d7034
fix build errors
DamienDeepgram Jul 14, 2024
e9a7d1c
fix build errors
DamienDeepgram Jul 14, 2024
848533f
fix build errors
DamienDeepgram Jul 14, 2024
017538b
fix build errors
DamienDeepgram Jul 14, 2024
7c4f559
fix build errors
DamienDeepgram Jul 14, 2024
196e46c
fix build errors
DamienDeepgram Jul 14, 2024
4f468e5
fix build errors
DamienDeepgram Jul 14, 2024
f32366f
fix build errors
DamienDeepgram Jul 14, 2024
8269b0c
Rrefactor SDK and add Speech to Text and Text to Speech features
DamienDeepgram Jul 17, 2024
fe27a1b
fix build error
DamienDeepgram Jul 17, 2024
a72c2b2
fix build error
DamienDeepgram Jul 17, 2024
1eb5b02
fix build error
DamienDeepgram Jul 17, 2024
2aa4b77
fix build error
DamienDeepgram Jul 17, 2024
639d56b
fix build error
DamienDeepgram Jul 17, 2024
7065bbd
fix build error
DamienDeepgram Jul 17, 2024
acedeab
fix build error
DamienDeepgram Jul 17, 2024
39e7201
fix build error
DamienDeepgram Jul 17, 2024
e6063d2
fix build error
DamienDeepgram Jul 17, 2024
843326f
fix build error
DamienDeepgram Jul 17, 2024
7cb90c7
fix build error
DamienDeepgram Jul 17, 2024
9a8d58d
fix build error
DamienDeepgram Jul 17, 2024
28ea919
fix build error
DamienDeepgram Jul 17, 2024
eb28f0c
fix build error
DamienDeepgram Jul 17, 2024
2617b35
fix build error
DamienDeepgram Jul 17, 2024
b184087
fix build error
DamienDeepgram Jul 17, 2024
3c4d4c5
fix build error
DamienDeepgram Jul 17, 2024
ff4baec
fix build error
DamienDeepgram Jul 17, 2024
df240ed
fix build error
DamienDeepgram Jul 17, 2024
78bb9dc
fix build error
DamienDeepgram Jul 17, 2024
00f07ca
fix build error
DamienDeepgram Jul 17, 2024
e595d08
fix build error
DamienDeepgram Jul 17, 2024
43a0dc6
fix build error
DamienDeepgram Jul 17, 2024
ad7f030
fix build error
DamienDeepgram Jul 17, 2024
c625ef4
fix build error
DamienDeepgram Jul 17, 2024
cdad768
fix build error
DamienDeepgram Jul 17, 2024
c7961b7
fix build error
DamienDeepgram Jul 17, 2024
dfbbf28
fix build error
DamienDeepgram Jul 17, 2024
e125a24
fix build error
DamienDeepgram Jul 17, 2024
dd1ec55
fix build error
DamienDeepgram Jul 17, 2024
1c1035d
fix build error
DamienDeepgram Jul 17, 2024
d28fd1a
fix build error
DamienDeepgram Jul 17, 2024
e3efc6c
fix build error
DamienDeepgram Jul 17, 2024
f239f97
Add encoding and endpointing Enums
DamienDeepgram Jul 17, 2024
5535930
Add encoding and endpointing Enums
DamienDeepgram Jul 17, 2024
b319e6f
Remove redundant example folders
DamienDeepgram Jul 17, 2024
c4140a2
remove test file
DamienDeepgram Jul 17, 2024
9ad966e
fix version
DamienDeepgram Jul 17, 2024
9df7a87
Add test file to gitignore
DamienDeepgram Jul 17, 2024
d55c154
update doc link
DamienDeepgram Jul 17, 2024
ccd7c8e
update doc link and add keywords
DamienDeepgram Jul 17, 2024
e2f199e
Add extra struct
DamienDeepgram Jul 17, 2024
ef7cae7
Add struct for callback_method
DamienDeepgram Jul 17, 2024
d5b50c9
Add extra struct
DamienDeepgram Jul 17, 2024
caf9dbb
Add DetectLanguage enum
DamienDeepgram Jul 17, 2024
425c001
Add keepalive as bool
DamienDeepgram Jul 17, 2024
bff63dd
handle booleans correctly
DamienDeepgram Jul 17, 2024
491f05b
fix detect_lanugage and add test
DamienDeepgram Jul 17, 2024
9174458
make Serialize a bool again
DamienDeepgram Jul 17, 2024
c573aaa
Remove Extra struct and use hasmap instead
DamienDeepgram Jul 17, 2024
5d61464
fix build errors
DamienDeepgram Jul 17, 2024
8175399
fix build errors
DamienDeepgram Jul 17, 2024
21e0e06
fix build errors
DamienDeepgram Jul 17, 2024
54f5993
fix build errors
DamienDeepgram Jul 17, 2024
0de7c8d
fix build errors
DamienDeepgram Jul 17, 2024
2240fd6
fix build errors
DamienDeepgram Jul 17, 2024
ed5503e
make all enums non_exhaustive
DamienDeepgram Jul 17, 2024
3d6d755
move files out of folders to avoid renaming
DamienDeepgram Jul 18, 2024
8817a6a
move files out of folders to avoid renaming
DamienDeepgram Jul 18, 2024
1a0bb25
Update src/common/options.rs
DamienDeepgram Jul 19, 2024
2807ac1
ensure keep alive is sending correctly and keeping the websocket open…
DamienDeepgram Jul 19, 2024
7b6e889
fix build formatting error
DamienDeepgram Jul 19, 2024
f81c238
set keepalive back to 10 seconds
DamienDeepgram Jul 19, 2024
92baab6
make error eprintln and remove debug println
DamienDeepgram Jul 19, 2024
410eebe
fix formatting error
DamienDeepgram Jul 19, 2024
46278b5
Add disabled to Endpointing and Detect Language and remove bool param
DamienDeepgram Jul 22, 2024
3e8c12e
remove speech_to_text and text_to_speech modules and move them into t…
DamienDeepgram Jul 23, 2024
7d468ed
rename to CustomDurationMs
DamienDeepgram Jul 23, 2024
038d3d3
update docs
DamienDeepgram Jul 23, 2024
ad2242d
Change order of pub and use
DamienDeepgram Jul 23, 2024
fadebc1
remove references to text_to_speech and speech_to_text
DamienDeepgram Jul 23, 2024
13ff6c6
fix typo
DamienDeepgram Jul 23, 2024
26ce6cb
remove new line
DamienDeepgram Jul 23, 2024
6d03392
fix build errors
DamienDeepgram Jul 23, 2024
e457271
fix build errors
DamienDeepgram Jul 23, 2024
d341743
remove old file
DamienDeepgram Jul 23, 2024
7e59a23
Add new options to Utterance for Custom Split
DamienDeepgram Jul 23, 2024
3db0ea5
rename prerecorded to rest and live to websocket
DamienDeepgram Jul 23, 2024
35bd503
remove brackets
DamienDeepgram Jul 23, 2024
6fbd64d
Update Multichannel options for model params
DamienDeepgram Jul 23, 2024
1ccd962
Update Multichannel options for model params
DamienDeepgram Jul 23, 2024
24ce8a8
fix build error
DamienDeepgram Jul 23, 2024
92a6b92
update formatting to fix build error
DamienDeepgram Jul 23, 2024
f31ea20
update formatting to fix build error
DamienDeepgram Jul 23, 2024
de1f85b
update formatting to fix build error
DamienDeepgram Jul 23, 2024
f3de673
add allow missing docs
DamienDeepgram Jul 23, 2024
9788882
remove link based on PR review
DamienDeepgram Jul 23, 2024
48a8801
update changelog
DamienDeepgram Jul 23, 2024
3f20bba
add enums for Speech to Text and add back in links
DamienDeepgram Jul 23, 2024
2527ec2
add enums updated to changelog
DamienDeepgram Jul 23, 2024
e9d2b28
fix build errors
DamienDeepgram Jul 23, 2024
9898f5c
fix build errors
DamienDeepgram Jul 23, 2024
314f92c
fix build errors
DamienDeepgram Jul 23, 2024
4b01cb1
fix build errors
DamienDeepgram Jul 23, 2024
2bf7ffb
remove commented out code
DamienDeepgram Jul 23, 2024
48acf39
lowercase EN to En
DamienDeepgram Jul 24, 2024
4bdeb60
lowercase EN to En
DamienDeepgram Jul 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,90 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.0] - 2024-07-23

### Migrating from 0.4.0 -> 0.6.0

Module Imports

```
use deepgram::{
--- transcription::prerecorded::{
+++ common::{
audio_source::AudioSource,
options::{Language, Options},
},
Deepgram, DeepgramError,
};
```

DamienDeepgram marked this conversation as resolved.
Show resolved Hide resolved
Streaming Changes

Now you can pass Options using stream_request_with_options
```
let options = Options::builder()
.smart_format(true)
.language(Language::en_US)
.build();

let mut results = dg
.transcription()
.stream_request_with_options(Some(&options))
.file(PATH_TO_FILE, AUDIO_CHUNK_SIZE, Duration::from_millis(16))
.await?
.start()
.await?;
```

### Changed

- Add streaming features
- Add support for pre-recorded features when streaming
- Add Speech to Text
- Refactor Code
DamienDeepgram marked this conversation as resolved.
Show resolved Hide resolved

Note that this modifies some public enum's which are used internally but might need to be taken into account
- Bumped the minor version but it might need a major bump?
- Maybe a 1.0.0 release?
DamienDeepgram marked this conversation as resolved.
Show resolved Hide resolved

### Streaming Features
- endpointing
- utterance_end_ms
- interim_results
- no_delay
- vad_events

### Streaming Functions
- keep_alive

### New Streaming Message Types
- Utterance End
- Speech Started

### Pre-Recorded Features
- encoding
- smart_format
- callback
- callback_method
- filler_words
- paragraphs
- diarize_version
- dictation
- measurements
- extra

### Pre-Recorded Audio Intelligence Features
- detect_entities
- sentiment
- topics
- summarize
- intents
- custom_intents
- custom_intent_mode
- topics
- custom_topics
- custom_topic_mode

## [Unreleased]
DamienDeepgram marked this conversation as resolved.
Show resolved Hide resolved
- Deprecate tiers and add explicit support for all currently available models.
DamienDeepgram marked this conversation as resolved.
Show resolved Hide resolved
- Expand language enum to include all currently-supported languages.
Expand Down
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,40 @@ speak = ["dep:rodio", "dep:pkg-config"]

[[example]]
name = "prerecorded_from_file"
path = "examples/transcription/prerecorded/prerecorded_from_file.rs"
path = "examples/transcription/rest/prerecorded_from_file.rs"
required-features = ["listen"]

[[example]]
name = "callback"
path = "examples/transcription/prerecorded/callback.rs"
path = "examples/transcription/rest/callback.rs"
required-features = ["listen"]

[[example]]
name = "make_prerecorded_request_builder"
path = "examples/transcription/prerecorded/make_prerecorded_request_builder.rs"
path = "examples/transcription/rest/make_prerecorded_request_builder.rs"
required-features = ["listen"]

[[example]]
name = "prerecorded_from_url"
path = "examples/transcription/prerecorded/prerecorded_from_url.rs"
path = "examples/transcription/rest/prerecorded_from_url.rs"
required-features = ["listen"]

[[example]]
name = "simple_stream"
path = "examples/transcription/live/simple_stream.rs"
path = "examples/transcription/websocket/simple_stream.rs"
required-features = ["listen"]

[[example]]
name = "microphone_stream"
path = "examples/transcription/live/microphone_stream.rs"
path = "examples/transcription/websocket/microphone_stream.rs"
required-features = ["listen"]

[[example]]
name = "text_to_speech_to_file"
path = "examples/speak/text_to_speech_to_file.rs"
path = "examples/speak/rest/text_to_speech_to_file.rs"
required-features = ["speak"]

[[example]]
name = "text_to_speech_to_stream"
path = "examples/speak/text_to_speech_to_stream.rs"
path = "examples/speak/rest/text_to_speech_to_stream.rs"
required-features = ["speak"]
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ async fn main() -> Result<(), DeepgramError> {
.encoding(Encoding::Linear16)
.sample_rate(44100)
.channels(2)
// .endpointing(Endpointing::Enabled())
.endpointing(Endpointing::CustomValue(300))
// .endpointing(Endpointing::Enabled)
DamienDeepgram marked this conversation as resolved.
Show resolved Hide resolved
.endpointing(Endpointing::CustomDurationMs(300))
.interim_results(true)
.utterance_end_ms(1000)
.vad_events(true)
Expand Down
4 changes: 2 additions & 2 deletions src/common/audio_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use reqwest::{header::CONTENT_TYPE, RequestBuilder};
use serde::Serialize;

/// Used as a parameter for [`Transcription::prerecorded`](crate::listen::speech_to_text::Transcription::prerecorded) and similar functions.
/// Used as a parameter for [`Transcription::prerecorded`](crate::Transcription::prerecorded) and similar functions.
#[derive(Debug)]
pub struct AudioSource(InternalAudioSource);

Expand Down Expand Up @@ -55,7 +55,7 @@ impl AudioSource {
})
}

/// Fill body
#[allow(missing_docs)]
pub fn fill_body(self, request_builder: RequestBuilder) -> RequestBuilder {
match self.0 {
InternalAudioSource::Url(url) => {
Expand Down
4 changes: 2 additions & 2 deletions src/common/batch_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// Returned by [`Transcription::prerecorded`](crate::listen::speech_to_text::Transcription::prerecorded).
/// Returned by [`Transcription::prerecorded`](crate::Transcription::prerecorded).
///
/// See the [Deepgram API Reference][api] for more info.
///
Expand All @@ -22,7 +22,7 @@ pub struct Response {
pub results: ListenResults,
}

/// Returned by [`Transcription::prerecorded_callback`](crate::listen::speech_to_text::Transcription::prerecorded_callback).
/// Returned by [`Transcription::prerecorded_callback`](crate::Transcription::prerecorded_callback).
///
/// See the [Deepgram Callback feature docs][docs] for more info.
///
Expand Down
74 changes: 35 additions & 39 deletions src/common/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::collections::HashMap;

use serde::{ser::SerializeSeq, Deserialize, Serialize};

/// Used as a parameter for [`Transcription::prerecorded`](crate::listen::speech_to_text::Transcription::prerecorded) and similar functions.
/// Used as a parameter for [`Transcription::prerecorded`](crate::Transcription::prerecorded) and similar functions.
#[derive(Debug, PartialEq, Clone)]
pub struct Options {
model: Option<Model>,
Expand Down Expand Up @@ -165,7 +165,7 @@ pub enum Endpointing {
Disabled,

#[allow(missing_docs)]
bd-g marked this conversation as resolved.
Show resolved Hide resolved
CustomValue(u32),
CustomDurationMs(u32),
}

/// Endpointing impl
Expand All @@ -175,7 +175,7 @@ impl Endpointing {
match self {
Endpointing::Enabled => "true".to_string(),
Endpointing::Disabled => "false".to_string(),
Endpointing::CustomValue(value) => value.to_string(),
Endpointing::CustomDurationMs(value) => value.to_string(),
}
}
}
Expand Down Expand Up @@ -603,13 +603,16 @@ pub struct Keyword {
#[non_exhaustive]
pub enum Utterances {
#[allow(missing_docs)]
Enabled {
#[allow(missing_docs)]
utt_split: Option<f64>,
},
Enabled,

#[allow(missing_docs)]
Disabled,

#[allow(missing_docs)]
CustomSplit {
#[allow(missing_docs)]
utt_split: Option<f64>,
},
}

/// Used as a parameter for [`OptionsBuilder::multichannel`].
Expand All @@ -621,21 +624,22 @@ pub enum Utterances {
#[non_exhaustive]
pub enum Multichannel {
#[allow(missing_docs)]
Enabled {
#[allow(missing_docs)]
models: Option<Vec<Model>>,
},
Enabled,

#[allow(missing_docs)]
Disabled,

#[allow(missing_docs)]
ModelPerChannel {
#[allow(missing_docs)]
models: Option<Vec<Model>>,
bd-g marked this conversation as resolved.
Show resolved Hide resolved
},
}

/// Builds an [`Options`] object using [the Builder pattern][builder].
///
/// Use it to set of Deepgram's features, excluding the Callback feature.
/// The Callback feature can be set when making the request by calling [`Transcription::prerecorded_callback`](crate::listen::speech_to_text::Transcription::prerecorded_callback).
///
/// [builder]: https://rust-unofficial.github.io/patterns/patterns/creational/builder.html
/// The Callback feature can be set when making the request by calling [`Transcription::prerecorded_callback`](crate::Transcription::prerecorded_callback).
#[derive(Debug, PartialEq, Clone)]
pub struct OptionsBuilder(Options);

Expand Down Expand Up @@ -717,25 +721,10 @@ impl OptionsBuilder {
/// .build();
/// ```
///
/// ```
/// # use deepgram::common::options::{Model, Options};
/// #
/// let options1 = Options::builder()
/// .multichannel_with_models([Model::Nova2Meeting, Model::Nova2Phonecall])
/// .model(Model::Nova2)
/// .build();
///
/// let options2 = Options::builder()
/// .multichannel(true)
/// .model(Model::Nova2)
/// .build();
///
/// assert_eq!(options1, options2);
/// ```
pub fn model(mut self, model: Model) -> Self {
self.0.model = Some(model);

if let Some(Multichannel::Enabled { models }) = &mut self.0.multichannel {
if let Some(Multichannel::ModelPerChannel { models }) = &mut self.0.multichannel {
*models = None;
}

Expand Down Expand Up @@ -963,7 +952,7 @@ impl OptionsBuilder {
/// ```
pub fn multichannel(mut self, multichannel: bool) -> Self {
self.0.multichannel = Some(if multichannel {
Multichannel::Enabled { models: None }
Multichannel::Enabled
} else {
Multichannel::Disabled
});
Expand Down Expand Up @@ -1073,7 +1062,7 @@ impl OptionsBuilder {
/// assert_eq!(options1, options2);
/// ```
pub fn multichannel_with_models(mut self, models: impl IntoIterator<Item = Model>) -> Self {
if let Some(Multichannel::Enabled {
if let Some(Multichannel::ModelPerChannel {
models: Some(old_models),
}) = &mut self.0.multichannel
{
Expand All @@ -1082,7 +1071,7 @@ impl OptionsBuilder {
old_models.extend(models);
} else {
// Multichannel with models already enabled
self.0.multichannel = Some(Multichannel::Enabled {
self.0.multichannel = Some(Multichannel::ModelPerChannel {
models: Some(models.into_iter().collect()),
});
}
Expand Down Expand Up @@ -1385,7 +1374,7 @@ impl OptionsBuilder {
/// ```
pub fn utterances(mut self, utterances: bool) -> Self {
self.0.utterances = Some(if utterances {
Utterances::Enabled { utt_split: None }
Utterances::Enabled
} else {
Utterances::Disabled
});
Expand Down Expand Up @@ -1413,7 +1402,7 @@ impl OptionsBuilder {
/// .build();
/// ```
pub fn utterances_with_utt_split(mut self, utt_split: f64) -> Self {
self.0.utterances = Some(Utterances::Enabled {
self.0.utterances = Some(Utterances::CustomSplit {
utt_split: Some(utt_split),
});
self
Expand Down Expand Up @@ -1961,15 +1950,20 @@ impl Serialize for SerializableOptions<'_> {
match multichannel {
// Multichannels with models is enabled
// Ignore self.model field
Some(Multichannel::Enabled {
Some(Multichannel::ModelPerChannel {
models: Some(models),
}) => {
seq.serialize_element(&("model", models_to_string(models)))?;
}

// Multichannel with models is not enabled
// Use self.model field
Some(Multichannel::Enabled { models: None } | Multichannel::Disabled) | None => {
Some(
Multichannel::ModelPerChannel { models: None }
| Multichannel::Enabled
| Multichannel::Disabled,
)
| None => {
if let Some(model) = model {
seq.serialize_element(&("model", model.as_ref()))?;
}
Expand Down Expand Up @@ -2016,7 +2010,8 @@ impl Serialize for SerializableOptions<'_> {

match multichannel {
Some(Multichannel::Disabled) => seq.serialize_element(&("multichannel", false))?,
Some(Multichannel::Enabled { models: _ }) => {
Some(Multichannel::Enabled) => seq.serialize_element(&("multichannel", true))?,
Some(Multichannel::ModelPerChannel { models: _ }) => {
// Multichannel models are serialized above if they exist
// This is done instead of serializing the self.model field
seq.serialize_element(&("multichannel", true))?;
Expand Down Expand Up @@ -2061,7 +2056,8 @@ impl Serialize for SerializableOptions<'_> {

match utterances {
Some(Utterances::Disabled) => seq.serialize_element(&("utterances", false))?,
Some(Utterances::Enabled { utt_split }) => {
Some(Utterances::Enabled) => seq.serialize_element(&("utterances", true))?,
Some(Utterances::CustomSplit { utt_split }) => {
seq.serialize_element(&("utterances", true))?;

if let Some(utt_split) = utt_split {
Expand Down
Loading
Loading