如何在Angular中将音频缓冲区转换为音频文件

时间:2019-06-07 17:27:46

标签: angular api audio

我有一个API,该API将要作为客户ID的响应返回音频作为响应返回到API并返回音频文件。为此,它提供了响应类型,例如数组缓冲区和隐蔽到音频缓冲区,但无法转换为音频文件

  export class UserdetailsComponent {
    private audioContext: AudioContext;
    GetAudioFile() {
     this.postData5 = new FormData();
     this.postData5.append('customer_id', this.customer_id);
     const headers: HttpHeaders =
     new HttpHeaders({
     'Access-Control-Allow-Origin':
      '*'
    });
     this.httpService.post('api url'
     , this.postData5, {
       headers: headers,
      responseType: "arraybuffer",
    })
     .subscribe((responseData) => {
      console.log(responseData);
      this.audiofile = responseData;
      this.checking = this.audioContext.decodeAudioData(
      responseData).then(function(decodedData) {
        // use the decoded data here
      console.log(decodedData)
       }); 
      console.log(this.checking);   
  });     
 }
  ngOnInit() {
this.audioContext = new AudioContext();
 }
}

我得到Audiobuffer的输出:output for AudioBuffer

0 个答案:

没有答案