Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(text-to-speech): add method to repair wav header for a stream #981

Merged
merged 1 commit into from
Oct 7, 2019

Conversation

dpopp07
Copy link
Contributor

@dpopp07 dpopp07 commented Oct 7, 2019

Starting with v4.0.0, the data from the HTTP synthesize method has been deserialized into a Stream rather than a Buffer. This introduced a problem with the repairWavHeader method, which takes in a Buffer and returns it synchronously.

This PR adds another method, repairWavHeaderStream. It takes in the Stream returned from the service and asynchronously reads it into memory and repairs it. The method returns a Promise that resolves with the repaired data.

I've updated the documentation, which was out of date and incorrect, to instruct users on how to use the new method.

Resolves #911

* the method takes a stream of wav data, reads it into memory, repairs the header, then returns a Promise that resolves with the repaired data as a buffer
@codecov-io
Copy link

codecov-io commented Oct 7, 2019

Codecov Report

Merging #981 into master will increase coverage by 22.22%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #981       +/-   ##
=========================================
+ Coverage   77.77%   100%   +22.22%     
=========================================
  Files           1      1               
  Lines           9      9               
  Branches        2      2               
=========================================
+ Hits            7      9        +2     
+ Misses          2      0        -2
Impacted Files Coverage Δ
test/resources/auth_helper.js 100% <0%> (+22.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8fc302...7b5d21c. Read the comment docs.

// in case of accidentally calling the wrong method
if (!isStream(wavFileAsStream)) {
return Buffer.isBuffer(wavFileAsStream)
? Promise.resolve(this.repairWavHeader(wavFileAsStream))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dpopp07 dpopp07 merged commit 42b0913 into master Oct 7, 2019
@dpopp07 dpopp07 deleted the repair-wav-header-stream branch October 7, 2019 18:44
watson-github-bot pushed a commit that referenced this pull request Oct 7, 2019
# [5.1.0](v5.0.0...v5.1.0) (2019-10-07)

### Features

* **text-to-speech:** add method to repair wav header for a stream ([#981](#981)) ([42b0913](42b0913))
@watson-github-bot
Copy link
Member

🎉 This PR is included in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Error: wavFileData.writeInt32LE is not a function at RequestWrapper.formatError
4 participants