Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public interface Service{
  2. @Streaming
  3. @Multipart
  4. @POST("/api/1.0/voice/audio")
  5. Call<ResponseBody> post(
  6. @Part("configuration") RequestBody configuration,
  7. @Part ("audio") RequestBody audio);
  8. }
  9.  
  10. Content-Type = multipart/form-data;boundary=----------------------------41464684449247792368259
  11. //HEADERS
  12. ----------------------------414646844492477923682591
  13. Content-Type: application/json; charset=utf-8
  14. Content-Disposition: form-data; name="configuration"
  15. //JSON data structure with different audio parameters.
  16. ----------------------------414646844492477923682591
  17. Content-Type: audio/wav; charset=utf-8
  18. Content-Disposition: form-data; name="audio"
  19. <audio_data>
  20. ----------------------------414646844492477923682591--
  21.  
  22. public RequestBody createPartForAudio(final byte[] samples){
  23. RequestBody requestBody = new RequestBody() {
  24. @Override
  25. public MediaType contentType() {
  26. return MediaType.parse("audio/wav; charset=utf-8");
  27. }
  28.  
  29. @Override
  30. public void writeTo(BufferedSink sink) throws IOException {
  31. //Source source = null;
  32. sink.write(samples);
  33.  
  34. }
  35. };
  36.  
  37. return requestBody;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement