Skip to content

Commit d9c2fc7

Browse files
SDK Update and Refactor (#76)
## Changes - Add streaming features - Add support for pre-recorded features when streaming - Add Speech to Text - Refactor Code ### 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
1 parent 641b751 commit d9c2fc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2619
-436
lines changed

.github/workflows/ci.yaml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,57 @@ env:
55
CARGO_TERM_COLOR: always
66
RUSTFLAGS: -D warnings
77
RUSTDOCFLAGS: -D warnings
8+
PKG_CONFIG_PATH: /usr/lib/pkgconfig
89

910
jobs:
1011
Features:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- uses: actions/checkout@v3
14-
- name: Install libasound2-dev
15+
- name: Install dependencies
1516
run: |
1617
sudo apt-get update
17-
sudo apt-get install libasound2-dev
18+
sudo apt-get install -y alsa pkg-config libasound2-dev
19+
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
1820
- name: Check no features
1921
run: cargo check --all-targets --no-default-features
20-
- name: Check prerecorded feature
21-
run: cargo check --all-targets --no-default-features --features=prerecorded
22-
- name: Check live feature
23-
run: cargo check --all-targets --no-default-features --features=live
22+
- name: Check listen feature
23+
run: cargo check --all-targets --no-default-features --features=listen
24+
- name: Check speak feature
25+
run: cargo check --all-targets --no-default-features --features=speak
26+
- name: Check manage feature
27+
run: cargo check --all-targets --no-default-features --features=manage
2428
Build:
2529
runs-on: ubuntu-latest
2630
steps:
2731
- uses: actions/checkout@v3
28-
- name: Install libasound2-dev
32+
- name: Install dependencies
2933
run: |
3034
sudo apt-get update
31-
sudo apt-get install libasound2-dev
35+
sudo apt-get install -y alsa pkg-config libasound2-dev
36+
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
3237
- name: Cargo Build
3338
run: cargo build --all-targets --all-features
3439
Clippy:
3540
runs-on: ubuntu-latest
3641
steps:
3742
- uses: actions/checkout@v3
38-
- name: Install libasound2-dev
43+
- name: Install dependencies
3944
run: |
4045
sudo apt-get update
41-
sudo apt-get install libasound2-dev
46+
sudo apt-get install -y alsa pkg-config libasound2-dev
47+
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
4248
- name: Cargo Clippy
4349
run: cargo clippy --all-targets --all-features
4450
Test:
4551
runs-on: ubuntu-latest
4652
steps:
4753
- uses: actions/checkout@v3
48-
- name: Install libasound2-dev
54+
- name: Install dependencies
4955
run: |
5056
sudo apt-get update
51-
sudo apt-get install libasound2-dev
57+
sudo apt-get install -y alsa pkg-config libasound2-dev
58+
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
5259
- name: Cargo Test
5360
run: cargo test --all --all-features
5461
Format:
@@ -61,12 +68,19 @@ jobs:
6168
runs-on: ubuntu-latest
6269
steps:
6370
- uses: actions/checkout@v3
71+
- name: Install dependencies
72+
run: |
73+
sudo apt-get update
74+
sudo apt-get install -y alsa pkg-config libasound2-dev
75+
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
6476
- name: Cargo Doc
6577
run: cargo doc --workspace --all-features
6678
Audit:
6779
runs-on: ubuntu-latest
6880
steps:
6981
- uses: actions/checkout@v3
82+
- name: Install dependencies
83+
run: sudo apt-get update
7084
- name: Install cargo-audit
7185
run: cargo install --locked cargo-audit
7286
- name: Remove Dev Dependencies
@@ -80,10 +94,11 @@ jobs:
8094
runs-on: ubuntu-latest
8195
steps:
8296
- uses: actions/checkout@v3
83-
- name: Install libasound2-dev
97+
- name: Install dependencies
8498
run: |
8599
sudo apt-get update
86-
sudo apt-get install libasound2-dev
100+
sudo apt-get install -y alsa pkg-config libasound2-dev
101+
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
87102
- name: Install Rust Nightly
88103
run: rustup toolchain install nightly
89104
- name: Cargo Build
@@ -101,6 +116,11 @@ jobs:
101116
runs-on: ubuntu-latest
102117
steps:
103118
- uses: actions/checkout@v3
119+
- name: Install dependencies
120+
run: |
121+
sudo apt-get update
122+
sudo apt-get install -y alsa pkg-config libasound2-dev
123+
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
104124
- name: Install cargo-semver-checks
105125
run: cargo install --locked cargo-semver-checks
106126
- name: Cargo SemVer Checks

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
/Cargo.lock
3+
your_output_file.wav

CHANGELOG.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,89 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [0.6.0] - 2024-07-23
8+
9+
### Migrating from 0.4.0 -> 0.6.0
10+
11+
Module Imports
12+
13+
```
14+
use deepgram::{
15+
--- transcription::prerecorded::{
16+
+++ common::{
17+
audio_source::AudioSource,
18+
options::{Language, Options},
19+
},
20+
Deepgram, DeepgramError,
21+
};
22+
```
23+
24+
Streaming Changes
25+
26+
Now you can pass Options using stream_request_with_options
27+
```
28+
let options = Options::builder()
29+
.smart_format(true)
30+
.language(Language::en_US)
31+
.build();
32+
33+
let mut results = dg
34+
.transcription()
35+
.stream_request_with_options(Some(&options))
36+
.file(PATH_TO_FILE, AUDIO_CHUNK_SIZE, Duration::from_millis(16))
37+
.await?
38+
.start()
39+
.await?;
40+
```
41+
42+
Some Enums have changed and may need to be updated
43+
44+
### Changed
45+
46+
- Add streaming features
47+
- Add support for pre-recorded features when streaming
48+
- Add Speech to Text
49+
- Reorganize Code
50+
51+
### Streaming Features
52+
- endpointing
53+
- utterance_end_ms
54+
- interim_results
55+
- no_delay
56+
- vad_events
57+
58+
### Streaming Functions
59+
- keep_alive
60+
61+
### New Streaming Message Types
62+
- Utterance End
63+
- Speech Started
64+
65+
### Pre-Recorded Features
66+
- encoding
67+
- smart_format
68+
- callback
69+
- callback_method
70+
- filler_words
71+
- paragraphs
72+
- diarize_version
73+
- dictation
74+
- measurements
75+
- extra
76+
77+
### Pre-Recorded Audio Intelligence Features
78+
- detect_entities
79+
- sentiment
80+
- topics
81+
- summarize
82+
- intents
83+
- custom_intents
84+
- custom_intent_mode
85+
- topics
86+
- custom_topics
87+
- custom_topic_mode
88+
89+
## [0.5.0]
890
- Deprecate tiers and add explicit support for all currently available models.
991
- Expand language enum to include all currently-supported languages.
1092
- Add (default on) feature flags for live and prerecorded transcription.

Cargo.toml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,86 @@
11
[package]
22
name = "deepgram"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Deepgram <[email protected]>"]
55
edition = "2021"
66
description = "Official Rust SDK for Deepgram's automated speech recognition APIs."
77
license = "MIT"
88
repository = "https://github.com/deepgram-devs/deepgram-rust-sdk"
9-
keywords = ["deepgram", "asr", "transcription", "ai", "speech-to-text"]
9+
keywords = ["deepgram", "transcription", "voice ai", "text-to-speech", "tts", "aura", "speech-to-text", "stt", "asr", "nova", "voice agent", "self-hosted"]
1010
categories = ["api-bindings", "multimedia::audio"]
1111

1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313

1414
[dependencies]
1515
# TODO Investigate which of these dependencies can go behind features.
16+
audio = "0.2.0"
1617
bytes = "1"
1718
futures = "0.3"
1819
http = "0.2"
1920
pin-project = "1"
2021
reqwest = { version = "0.11.22", default-features = false, features = ["json", "rustls-tls", "stream"] }
21-
serde = { version = "1", features = ["derive"] }
22+
rodio = { version = "0.17.0", optional = true }
23+
serde = { version = "1.0.25", features = ["derive"] }
2224
serde_json = "1"
25+
serde_urlencoded = "0.7"
2326
thiserror = "1"
24-
tokio = { version = "1.13.0", features = ["full"] }
27+
tokio = { version = "1.38.0", features = ["full"] }
28+
tokio-stream = "0.1.15"
2529
tokio-tungstenite = { version = "0.20.1", features = ["rustls-tls-webpki-roots"], optional = true }
2630
tokio-util = { version = "0.7.1", features = ["codec", "io"] }
2731
tungstenite = { version = "0.20.1", optional = true }
2832
url = "2"
2933
uuid = { version = "1", features = ["serde"] }
3034
# Dependencies below are specified only to satisfy minimal-versions.
3135
proc-macro2 = "1.0.60"
36+
pkg-config = { version = "0.3.30", optional = true }
3237

3338
[dev-dependencies]
34-
pkg-config = "0.3.27"
3539
cpal = "0.13"
3640
crossbeam = "0.8"
3741

3842
[features]
39-
default = ["prerecorded", "live"]
40-
live = ["dep:tungstenite", "dep:tokio-tungstenite"]
41-
prerecorded = []
43+
default = ["manage", "listen", "speak"]
44+
manage = []
45+
listen = ["dep:tungstenite", "dep:tokio-tungstenite"]
46+
speak = ["dep:rodio", "dep:pkg-config"]
4247

4348
[[example]]
4449
name = "prerecorded_from_file"
45-
required-features = ["prerecorded"]
50+
path = "examples/transcription/rest/prerecorded_from_file.rs"
51+
required-features = ["listen"]
4652

4753
[[example]]
4854
name = "callback"
49-
required-features = ["prerecorded"]
55+
path = "examples/transcription/rest/callback.rs"
56+
required-features = ["listen"]
5057

5158
[[example]]
5259
name = "make_prerecorded_request_builder"
53-
required-features = ["prerecorded"]
60+
path = "examples/transcription/rest/make_prerecorded_request_builder.rs"
61+
required-features = ["listen"]
62+
63+
[[example]]
64+
name = "prerecorded_from_url"
65+
path = "examples/transcription/rest/prerecorded_from_url.rs"
66+
required-features = ["listen"]
67+
68+
[[example]]
69+
name = "simple_stream"
70+
path = "examples/transcription/websocket/simple_stream.rs"
71+
required-features = ["listen"]
5472

5573
[[example]]
5674
name = "microphone_stream"
57-
required-features = ["live"]
75+
path = "examples/transcription/websocket/microphone_stream.rs"
76+
required-features = ["listen"]
5877

5978
[[example]]
60-
name = "prerecorded_from_url"
61-
required-features = ["prerecorded"]
79+
name = "text_to_speech_to_file"
80+
path = "examples/speak/rest/text_to_speech_to_file.rs"
81+
required-features = ["speak"]
6282

6383
[[example]]
64-
name = "simple_stream"
65-
required-features = ["live"]
84+
name = "text_to_speech_to_stream"
85+
path = "examples/speak/rest/text_to_speech_to_stream.rs"
86+
required-features = ["speak"]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ To make sure our community is safe for all, be sure to review and agree to our
4646
[Code of Conduct](./CODE_OF_CONDUCT.md). Then see the
4747
[Contributing Guidelines](./CONTRIBUTING.md) for more information.
4848

49+
### Build the SDK
50+
51+
```sh
52+
cargo build
53+
```
54+
4955
## Getting Help
5056

5157
We love to hear from you so if you have questions, comments or find a bug in the

examples/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Running Examples
2+
3+
### Setting Env Vars
4+
5+
```sh
6+
export FILENAME=./examples/audio/Bueller-Life-moves-pretty-fast.mp3
7+
```
8+
9+
### Running the examples
10+
11+
```sh
12+
cargo run --example prerecorded_from_url
13+
```
14+
15+
```sh
16+
cargo run --example simple_stream
17+
```
18+
19+
```sh
20+
cargo run --example advanced_stream
21+
```

examples/audio/bueller.wav

2.96 MB
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.

examples/prerecorded_from_url.rs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)