-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Example of getting bytes instead of saving directly to file for speech #177
base: main
Are you sure you want to change the base?
Conversation
@@ -159,7 +159,7 @@ packages: | |||
path: ".." | |||
relative: true | |||
source: path | |||
version: "4.1.4" | |||
version: "5.1.0" |
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.
this was automatic, please revert if incorrect
@@ -13,6 +14,14 @@ abstract class CreateInterface { | |||
Directory? outputDirectory, | |||
}); | |||
|
|||
Future<Uint8List> createSpeechBytes({ |
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.
couldn't create an overload with the same param names, rename if unsuitable.
return response.bodyBytes; | ||
} | ||
|
||
static Future<http.Response> postAndGetResponse({ |
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.
separated the basics of getting the response with bytes data so we still have the error handling/logging
}) async { | ||
|
||
var response = await postAndGetResponse(to: to, body: body, client: client); | ||
return response.bodyBytes; |
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.
in this case just get the bytes, should mean we can play with AudioPlayer BytesSource
data source on platforms which don't support file operations
This modifies the speech API to allow getting the bytes directly to play.
This will allow platforms like web which cannot write files to play the audio, and will allow other platforms to play the audio without adding file system permissions to write the temporary files.
tests as working with code: