-
Notifications
You must be signed in to change notification settings - Fork 24
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
Streaming callbacks #85
Conversation
.file(PATH_TO_FILE, AUDIO_CHUNK_SIZE, FRAME_DELAY) | ||
.await?; | ||
|
||
println!("Deepgram Request ID: {}", results.request_id()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here - simple way to grab request ID from the TranscriptionStream
@@ -737,6 +759,10 @@ impl<'a> WebsocketHandle { | |||
// eprintln!("<handle> receiving response: {resp:?}"); | |||
resp | |||
} | |||
|
|||
pub fn request_id(&self) -> Uuid { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docs to this function, and please mention that the request ID is needed for support on issues that come up with a particular request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/lib.rs
Outdated
|
||
/// A Deepgram API server response was not in the expected format. | ||
#[error("The Deepgram API server response was not in the expected format: {0}")] | ||
UnexpectedServerResponse(String), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this from String to anyhow::Error
, which is more flexible, and allows us to provide better-structured errors. (Then at error construction time, you can use anyhow!("missing request request_id")
and anyhow!("malformed request_id: {:?}", request_id)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Proposed changes
Allows specifying a callback for streaming requests. See docs.
Types of changes
Checklist
Further comments
Added a doc to the
callback_method
option to clarify the option is only respected for pre-recorded requests. May be worth making a breaking change in the future and refusing to accept streaming requests that attempt to set this option?