Android-在使用Volley将MP3发送到OpenAIWhisper时出现意外的400响应代码。
创始人
2024-08-19 23:00:44
0
  1. 确保已经正确地配置了Volley库及其依赖项。
  2. 检查发送的MP3文件是否存在,且路径正确。
  3. 确保发送的请求中包括所需的参数,如API键等。
  4. 检查所需的参数是否正确,尤其是文件类型是否正确等。
  5. 确保API键是否有效。
  6. 检查请求的URL是否正确。
  7. 确保服务器端是否正确地响应了请求。
  8. 在收到400响应代码时,查看服务器端返回的错误消息,以了解问题的具体原因。

示例代码:

String url = "http://openai-whisper.custom.ai/post_mp3";
File file = new File("path/to/file.mp3");
byte[] bytes = FileUtils.readFileToByteArray(file);
String credentials = "API_KEY:passowrd";

StringRequest request = new StringRequest(
  Request.Method.POST,
  url,
  new Response.Listener() {
    @Override
    public void onResponse(String response) {
      // Handle response here
    }
  },
  new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
      // Handle error here
    }
  }
) {
  @Override
  public Map getHeaders() throws AuthFailureError {
    HashMap headers = new HashMap<>();
    headers.put("Authorization", "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP));
    return headers;
  }

  @Override
  public byte[] getBody() throws AuthFailureError {
    return bytes;
  }

  @Override
  public String getBodyContentType() {
    return "audio/mpeg";
  }
};

RequestQueue queue = Volley.newRequestQueue(context);
queue.add(request);

相关内容

热门资讯

据相关数据显示!aapoker... 据相关数据显示!aapoker脚本怎么用(透视)hhpoker俱乐部是干嘛的-都是是有挂(哔哩哔哩)...
复盘辅助挂!购买的wpk辅助在... 复盘辅助挂!购买的wpk辅助在哪里下载(透视)wpk模拟器是什么-原来是有挂(哔哩哔哩);1、购买的...
透视辅助!德普辅助软件(透视)... 透视辅助!德普辅助软件(透视)德普之星透视软件免费入口官网-果然存在有挂(哔哩哔哩)1、完成德普之星...
透视模拟器!wepoker辅助... 透视模拟器!wepoker辅助器(透视)wepoker软件辅助程序-都是存在有挂(哔哩哔哩)1、让任...
据悉!aapoker公共底牌(... 据悉!aapoker公共底牌(透视)hhpoker是正品吗-都是存在有挂(哔哩哔哩)1、据悉!aap...
透视科技!wpk真的有透视嘛(... 透视科技!wpk真的有透视嘛(透视)wpk真的有透视嘛-果然有挂(哔哩哔哩)1)wpk真的有透视嘛有...
今年以来!aapoker辅助怎... 今年以来!aapoker辅助怎么用(透视)hhpoker辅助挂下载-一贯是有挂(哔哩哔哩)aapok...
透视插件!aapoker怎么拿... 透视插件!aapoker怎么拿好牌(透视)德州hhpoker脚本-本来存在有挂(哔哩哔哩)1、让任何...
透视透视挂!如何下载德普之星辅... 透视透视挂!如何下载德普之星辅助软件(透视)德普之星透视辅助软件是真的吗-都是有挂(哔哩哔哩)1、这...
昨日!aapoker脚本怎么用... 您好,aapoker脚本怎么用这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054...