watson-developer-cloud / node-red-labs

Node-RED labs on the use of the Watson Developer Cloud services
MIT License
209 stars 367 forks source link

Text to speech lab - issue with generated .wav file #89

Closed hannahsaid closed 8 years ago

hannahsaid commented 8 years ago

When I follow the steps in the 'text to speech' lab, the .wav file is created but I receive the following error when trying to play it with Windows Media Player:

Windows Media Player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file.

Any suggestions appreciated.

hansb001 commented 8 years ago

On 29 Feb 2016, at 14:38, hannahsaid notifications@github.com wrote:

When I follow the steps in the 'text to speech' lab, the .wav file is created but I receive the following error when trying to play it with Windows Media Player:

Windows Media Player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file.

Any suggestions appreciated.

— Reply to this email directly or view it on GitHub https://github.com/watson-developer-cloud/node-red-labs/issues/89.

You probably miss the right codecs for Windows Media player to play WAV. Have you tried another media player?

hannahsaid commented 8 years ago

Sorry I should have said - I am able to play other .wav files with Windows Media Player. I think it is an issue with the generated file.

chughts commented 8 years ago

Post your flow here so we can take a look.

hannahsaid commented 8 years ago

[{"id":"94692229.74bf1","type":"http in","z":"fc7acfd3.ecaf38","name":"","url":"/tts/sayit","method":"get","swaggerDoc":"","x":102.89999389648438,"y":38.399993896484375,"wires":[["739bcf34.a1b13"]]},{"id":"739bcf34.a1b13","type":"change","z":"fc7acfd3.ecaf38","name":"text to payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"msg.payload.text_to_say","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":162.90000915527344,"y":97.39999389648438,"wires":[["a1f6fed0.40f488"]]},{"id":"a1f6fed0.40f488","type":"watson-text-to-speech","z":"fc7acfd3.ecaf38","name":"","lang":"english","voice":"en-US_MichaelVoice","format":"audio/wav","x":241.90000915527344,"y":160.40000915527344,"wires":[["df1f17c6.6b9aa8"]]},{"id":"df1f17c6.6b9aa8","type":"change","z":"fc7acfd3.ecaf38","name":"speech to payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"msg.speech","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":314.90000915527344,"y":227.59999084472656,"wires":[["ec75d297.86e9f"]]},{"id":"ec75d297.86e9f","type":"function","z":"fc7acfd3.ecaf38","name":"Set headers","func":"msg.headers={ 'Content-Type': 'audio/wav'};\nreturn msg;","outputs":1,"noerr":0,"x":376.9000244140625,"y":275.5999755859375,"wires":[["e724ea47.1bf918"]]},{"id":"e724ea47.1bf918","type":"http response","z":"fc7acfd3.ecaf38","name":"","x":444.90000915527344,"y":324.99998474121094,"wires":[]}]

hannahsaid commented 8 years ago

I get the same issue if I import the solution and use that instead of the flow I created.

philippe-gregoire commented 8 years ago

AFAIK, the .wav file format is a container, it can have varying formats inside. As Hans mentionned, I would think that the specific format that we get from Watson cannot be played by your WMP, maybe because the codec are missing (although this would be strange as this format is probably pretty basic)

philippe-gregoire commented 8 years ago

Actually, we should either try to play your Wav to a machine where the flow gives playable wav (to check if it is somehow corrupted), or send you a wav that we know is playable on our WMP (to validate or not if your WMP has maybe an issue).

hannahsaid commented 8 years ago

Thanks for your responses. Apologies, I didn't spot yesterday that the file that is being created is not getting the .wav extension so yes, I think it is being corrupted somehow. I've put the output file in the attached zip. sayit.zip

hannahsaid commented 8 years ago

The file is created with the correct extension if I change the function to: msg.headers={ 'Content-Type': 'audio/x-wav'}; return msg; It still can't be played with my Windows Media Player though ... sayitV2.zip

chughts commented 8 years ago

@hannahsaid How are you running the flow that you have submitted? What you have created is a REST API. As it is a GET it will be looking for any submitted parameters in msg.res. So from a browser you should be calling it as ....../tts/sayit?text_to_say="Try saying this"

I have imported your flow, and run it (i am using firefox) and it works.

hannahsaid commented 8 years ago

Thanks Soheel, that is how I am calling the REST API. Perhaps its an issue with my Windows Media Player codecs ...

chughts commented 8 years ago

More likely to be a browser plugin related.

hannahsaid commented 8 years ago

Fixed at last :)

The output .wav was very small so I tried renaming it as a .txt to see the contents, which was 'msg.speech'

This led me to discover I had an error in my second change node (see attachment). It seems that the type was set to string. I've corrected this and its now working.

Thanks for your suggestions. correctedtts