How to play a wav file with hermes/audioServer/<siteId>/playBytes/<requestId>? Example needed


#1

Hi,

I try to play a sound wav through hermes but I need a more detailed example to understand the command.

I am in a JavaScript script using MQTT to manipulate snipes. It looks like:
getAction(“Mqtt”).static.publish(“snips”, “hermes/audioServer/” + siteId + “/playBytes/1”, “{”/usr/share/snips/assistant/custom_dialogue/sound/start_of_input.wav"}");

Anybody a hint for me?

Thanks in advance!
freddy


#2

You need to publish the wav file as a buffer, not as a filename.
That is why the topic has the name: playBytes, it plays bytes :slight_smile:


#3

Not sure about the java script part in particular, but you need to send it as a binary payload and that’s all. So you need to read that wav file into a buffer and send it. Using paho you may need to set the payloadFormatIndicator to false to indicate binary.


#4

Thanks @Romkabouter and @tschmidty!
I’ll try to take it to the next level. :slight_smile:

freddy


#5

this is how i do it on the command line:
{{path to}}/mosquitto_pub -h {{ mqtt hostname }} -p 1883 -t 'hermes/audioServer/{{ site_id }}/playBytes/{{ session_id }}' -f '{{ path to wav file }}'


#6

Hi @diplix,

thank you!

Is it a local path or a server path (with Snips)?

freddy


#7

i use local wav files, but as long as the path resolves to a valid and accessible wav file, any path should work.