File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -182,15 +182,14 @@ fn f32_to_i16(sample: f32) -> i16 {
182
182
/// also be executed in an async runtime.
183
183
async fn connect_to_deepgram (
184
184
) -> tokio_tungstenite:: WebSocketStream < tokio_tungstenite:: MaybeTlsStream < tokio:: net:: TcpStream > > {
185
+ let api_key = std:: env:: var ( "DEEPGRAM_API_KEY" ) . expect ( "Deepgram API Key is required." ) ;
186
+
185
187
// prepare the connection request with the api key authentication
186
188
// TODO: don't hardcode the encoding, sample rate, or number of channels
187
- let builder = http:: Request :: builder ( )
189
+ let request = http:: Request :: builder ( )
188
190
. method ( http:: Method :: GET )
189
- . uri ( "wss://api.deepgram.com/v1/listen?encoding=linear16&sample_rate=44100&channels=1" ) ;
190
-
191
- let api_key = std:: env:: var ( "DEEPGRAM_API_KEY" ) . expect ( "Deepgram API Key is required." ) ;
192
- let builder = builder. header ( "Authorization" , format ! ( "Token {}" , api_key) ) ;
193
- let request = builder
191
+ . uri ( "wss://api.deepgram.com/v1/listen?encoding=linear16&sample_rate=44100&channels=1" )
192
+ . header ( "Authorization" , format ! ( "Token {}" , api_key) )
194
193
. body ( ( ) )
195
194
. expect ( "Failed to build a connection request to Deepgram." ) ;
196
195
You can’t perform that action at this time.
0 commit comments