Skip to content

Commit 1156e0c

Browse files
authored
Update dependencies to latest version (#117)
* Update dependencies to latest version * Fix clippy issues when using rustc 1.88
1 parent 5b083b1 commit 1156e0c

19 files changed

+86
-126
lines changed

Cargo.toml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,37 @@ categories = ["api-bindings", "multimedia::audio"]
2020
[dependencies]
2121
# TODO Investigate which of these dependencies can go behind features.
2222
bytes = "1"
23-
futures = "0.3"
24-
http = "0.2"
23+
futures = "^0.3"
24+
http = "1.3"
2525
pin-project = "1"
26-
reqwest = { version = "0.11.22", default-features = false, features = [
26+
reqwest = { version = "^0.12", default-features = false, features = [
2727
"json",
2828
"rustls-tls",
2929
"stream",
3030
] }
31-
serde = { version = "1.0.215", features = ["derive"] }
31+
serde = { version = "^1.0.219", features = ["derive"] }
3232
serde_json = "1"
3333
serde_urlencoded = "0.7"
34-
thiserror = "1"
35-
tokio = { version = "1.38.0", features = ["full"] }
36-
tokio-stream = "0.1.15"
37-
tokio-tungstenite = { version = "0.20.1", features = [
34+
thiserror = "2"
35+
tokio = { version = "^1.45.1", features = ["full"] }
36+
tokio-stream = "^0.1.17"
37+
tokio-tungstenite = { version = "^0.27.0", features = [
3838
"rustls-tls-webpki-roots",
3939
], optional = true }
40-
tokio-util = { version = "0.7.1", features = ["codec", "io"] }
41-
tungstenite = { version = "0.20.1", optional = true }
40+
tokio-util = { version = "^0.7", features = ["codec", "io"] }
41+
tungstenite = { version = "^0.27", optional = true }
4242
url = "2"
4343
uuid = { version = "1", features = ["serde"] }
4444
# Dependencies below are specified only to satisfy minimal-versions.
45-
sha256 = "1.5.0"
46-
anyhow = "1.0.86"
45+
sha256 = "^1.6.0"
46+
anyhow = "^1.0.98"
47+
tracing = ">=0.1.41"
4748

4849
[dev-dependencies]
49-
cpal = "0.13"
50+
cpal = "^0.16"
5051
crossbeam = "0.8"
5152
audio = "0.2.0"
52-
rodio = { version = "0.17.0" }
53+
rodio = { version = "0.20" }
5354
pkg-config = { version = "0.3.30" }
5455

5556
[features]

examples/speak/rest/text_to_speech_to_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async fn main() -> Result<(), DeepgramError> {
3131
.await?;
3232

3333
let elapsed_time = start_time.elapsed();
34-
println!("Time to download audio: {:.2?}", elapsed_time);
34+
println!("Time to download audio: {elapsed_time:.2?}");
3535

3636
Ok(())
3737
}

examples/speak/rest/text_to_speech_to_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async fn main() -> Result<(), DeepgramError> {
137137
// Print timing information if not already printed
138138
if !time_to_first_byte_printed {
139139
let elapsed_time = start_time.elapsed();
140-
println!("Time to first audio byte: {:.2?}", elapsed_time);
140+
println!("Time to first audio byte: {elapsed_time:.2?}");
141141
time_to_first_byte_printed = true;
142142
}
143143

examples/transcription/rest/make_prerecorded_request_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async fn main() -> Result<(), DeepgramError> {
3939
let response: Response = customized_request_builder.send().await?.json().await?;
4040

4141
let transcript = &response.results.channels[0].alternatives[0].transcript;
42-
println!("{}", transcript);
42+
println!("{transcript}");
4343

4444
Ok(())
4545
}

examples/transcription/rest/prerecorded_from_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn main() -> Result<(), DeepgramError> {
3333
.await?;
3434

3535
let transcript = &response.results.channels[0].alternatives[0].transcript;
36-
println!("{}", transcript);
36+
println!("{transcript}");
3737

3838
Ok(())
3939
}

examples/transcription/rest/prerecorded_from_url.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ async fn main() -> Result<(), DeepgramError> {
5151
.await?;
5252

5353
let transcript = &response.results.channels[0].alternatives[0].transcript;
54-
println!("{}", transcript);
54+
println!("{transcript}");
5555

56-
println!("{:?}", response);
56+
println!("{response:?}");
5757

5858
Ok(())
5959
}

examples/transcription/websocket/callback_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async fn main() -> Result<(), DeepgramError> {
4747

4848
println!("Deepgram Request ID: {}", results.request_id());
4949
while let Some(result) = results.next().await {
50-
println!("got: {:?}", result);
50+
println!("got: {result:?}");
5151
}
5252

5353
Ok(())

examples/transcription/websocket/microphone_stream.rs

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::thread;
33

44
use bytes::{BufMut, Bytes, BytesMut};
55
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
6-
use cpal::Sample;
6+
use cpal::{Sample, SampleFormat};
77
use crossbeam::channel::RecvError;
88
use deepgram::common::options::Encoding;
99
use futures::channel::mpsc::{self, Receiver as FuturesReceiver};
@@ -12,6 +12,25 @@ use futures::SinkExt;
1212

1313
use deepgram::{Deepgram, DeepgramError};
1414

15+
macro_rules! create_stream {
16+
($device:ident, $config:expr, $sync_tx:ident, $sample_type:ty) => {
17+
$device
18+
.build_input_stream(
19+
&$config.into(),
20+
move |data: &[$sample_type], _: &_| {
21+
let mut bytes = BytesMut::with_capacity(data.len() * 2);
22+
for sample in data {
23+
bytes.put_i16_le(sample.to_sample());
24+
}
25+
$sync_tx.send(bytes.freeze()).unwrap();
26+
},
27+
|_| panic!(),
28+
None,
29+
)
30+
.unwrap()
31+
};
32+
}
33+
1534
fn microphone_as_stream() -> FuturesReceiver<Result<Bytes, RecvError>> {
1635
let (sync_tx, sync_rx) = crossbeam::channel::unbounded();
1736
let (mut async_tx, async_rx) = mpsc::channel(1);
@@ -30,45 +49,12 @@ fn microphone_as_stream() -> FuturesReceiver<Result<Bytes, RecvError>> {
3049
// dbg!(&config);
3150

3251
let stream = match config.sample_format() {
33-
cpal::SampleFormat::F32 => device
34-
.build_input_stream(
35-
&config.into(),
36-
move |data: &[f32], _: &_| {
37-
let mut bytes = BytesMut::with_capacity(data.len() * 2);
38-
for sample in data {
39-
bytes.put_i16_le(sample.to_i16());
40-
}
41-
sync_tx.send(bytes.freeze()).unwrap();
42-
},
43-
|_| panic!(),
44-
)
45-
.unwrap(),
46-
cpal::SampleFormat::I16 => device
47-
.build_input_stream(
48-
&config.into(),
49-
move |data: &[i16], _: &_| {
50-
let mut bytes = BytesMut::with_capacity(data.len() * 2);
51-
for sample in data {
52-
bytes.put_i16_le(*sample);
53-
}
54-
sync_tx.send(bytes.freeze()).unwrap();
55-
},
56-
|_| panic!(),
57-
)
58-
.unwrap(),
59-
cpal::SampleFormat::U16 => device
60-
.build_input_stream(
61-
&config.into(),
62-
move |data: &[u16], _: &_| {
63-
let mut bytes = BytesMut::with_capacity(data.len() * 2);
64-
for sample in data {
65-
bytes.put_i16_le(sample.to_i16());
66-
}
67-
sync_tx.send(bytes.freeze()).unwrap();
68-
},
69-
|_| panic!(),
70-
)
71-
.unwrap(),
52+
SampleFormat::F32 => create_stream!(device, config, sync_tx, f32),
53+
SampleFormat::I16 => create_stream!(device, config, sync_tx, i16),
54+
SampleFormat::U16 => create_stream!(device, config, sync_tx, u16),
55+
sample_format => {
56+
panic!("Unsupported sample format: {sample_format:?}");
57+
}
7258
};
7359

7460
stream.play().unwrap();
@@ -109,7 +95,7 @@ async fn main() -> Result<(), DeepgramError> {
10995

11096
println!("Deepgram Request ID: {}", results.request_id());
11197
while let Some(result) = results.next().await {
112-
println!("got: {:?}", result);
98+
println!("got: {result:?}");
11399
}
114100

115101
Ok(())

examples/transcription/websocket/simple_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn main() -> Result<(), DeepgramError> {
4141

4242
println!("Deepgram Request ID: {}", results.request_id());
4343
while let Some(result) = results.next().await {
44-
println!("got: {:?}", result);
44+
println!("got: {result:?}");
4545
}
4646

4747
Ok(())

src/common/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ impl Serialize for SerializableOptions<'_> {
22882288

22892289
if let Some(extra) = extra {
22902290
for (key, value) in extra.iter() {
2291-
seq.serialize_element(&("extra", format!("{}:{}", key, value)))?;
2291+
seq.serialize_element(&("extra", format!("{key}:{value}")))?;
22922292
}
22932293
}
22942294

@@ -2706,7 +2706,7 @@ mod serialize_options_tests {
27062706

27072707
let expected = limited_letters
27082708
.iter()
2709-
.map(|letter| format!("{}={}", key, letter))
2709+
.map(|letter| format!("{key}={letter}"))
27102710
.collect::<Vec<String>>()
27112711
.join("&");
27122712

0 commit comments

Comments
 (0)