unity3d百度语音合成mp3流转换byte[]失败

  using (Stream stream = response.GetResponseStream())
        {
            buffer2 = new byte[stream.Length];
            stream.Read(buffer2, 0, buffer2.Length);

        }


stream.Length失败



解决方案 

1、用unity自带的www类

2、https://bbs.csdn.net/topics/360163784

byte[] result;
byte[] buffer = new byte[4096];
 
WebRequest wr = WebRequest.Create(someUrl);
 
using(WebResponse response = wr.GetResponse())
{
   using(Stream responseStream = response.GetResponseStream())
   {
      using(MemoryStream memoryStream = new MemoryStream())
      {
         int count = 0;
         do
         {
            count = responseStream.Read(buffer, 0, buffer.Length);
            memoryStream.Write(buffer, 0, count);
 
         } while(count != 0);
 
         result = memoryStream.ToArray();
 
      }
   }
}

发布了52 篇原创文章 · 获赞 13 · 访问量 3万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览