调用返回3300,怎么办
yangcan1930 发布于2016-04 浏览:945 回复:1
0
收藏

我发现调用后返回总是错误,错误码3300,为什么呢?代码如下

BaiduRecoParams p = new BaiduRecoParams();
            p.format = "wav";
            FileStream fs = new FileStream(FileName, FileMode.Open);
            byte[] voice = new byte[fs.Length];
            fs.Read(voice, 0, voice.Length);
            fs.Close();
            p.len = (int)voice.Length;
            p.rate = 8000;
            p.channel = 1;
            p.token = token;
            p.cuid = cuid;
            //p.speech = Convert.ToBase64String(voice).Replace('+', '-').Replace('/', '_');
            p.speech = Convert.ToBase64String(voice);
            string json = JsonConvert.SerializeObject(p);


            HttpWebRequest request = WebRequest.Create("http://vop.baidu.com/server_api") as HttpWebRequest;
            request.Method = "POST";
            request.ContentType = "application/json; charset=utf-8";

            Stream stream = request.GetRequestStream();
            StreamWriter write = new StreamWriter(stream);
            write.Write(json);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            if (request.HaveResponse)
            {
                Stream s = response.GetResponseStream();
                StreamReader responseReader = new StreamReader(s);
                string content = responseReader.ReadToEnd();
                JObject obj = JObject.Parse(content);
                string re = obj["result"].ToString();
            }                                    

收藏
点赞
0
个赞
共1条回复 最后由mosal4hi回复于2016-04
#2mosal4hi回复于2016-04

确认下几个问题:1是否有sn,如果有请提供sn及请求时间

2.如果没有sn,请确认下json格式是否正确,参数类型是否有误。

0
TOP
切换版块