svrooij / node-sonos-tts-polly

A text-to-speech server for node-sonos-ts
https://www.npmjs.com/package/@svrooij/sonos-tts-polly
MIT License
9 stars 1 forks source link

API does not generate mp3 files #13

Open tsoybe opened 1 year ago

tsoybe commented 1 year ago

I'm using:

docker run --env-file tts_env -p 5601:5601 svrooij/sonos-tts-polly

I can get the list of voices with:

GET http://[IP]:5601/api/voices

Answer:

[
    {
        "Gender": "Male",
        "Id": "Kevin",
        "LanguageCode": "en-US",
        "LanguageName": "US English",
        "Name": "Kevin",
        "SupportedEngines": [
            "neural"
        ]
    },

...

But if I use:

POST http://[IP]:5601/api/generate

with payload:

{ text: "Hello world", lang: "en-US", gender: "male", engine: "neural" }

I get this Error:

Error creating cache file TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at PollyTTSServer.<anonymous> (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:195:75)
    at step (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:52:23)
    at Object.next (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:33:53)
    at /usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:23:12)
    at PollyTTSServer.generateCacheFile (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:186:16)
    at PollyTTSServer.<anonymous> (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:165:41)
    at step (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:52:23)
    at Object.next (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:33:53) {
  [stack]: "TypeError: Cannot read properties of undefined (reading 'toLowerCase')\n" +
    '    at PollyTTSServer.<anonymous> (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:195:75)\n' +
    '    at step (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:52:23)\n' +
    '    at Object.next (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:33:53)\n' +
    '    at /usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:27:71\n' +
    '    at new Promise (<anonymous>)\n' +
    '    at __awaiter (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:23:12)\n' +
    '    at PollyTTSServer.generateCacheFile (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:186:16)\n' +
    '    at PollyTTSServer.<anonymous> (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:165:41)\n' +
    '    at step (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:52:23)\n' +
    '    at Object.next (/usr/local/lib/node_modules/@svrooij/sonos-tts-polly/dist/server.js:33:53)',
  [message]: "Cannot read properties of undefined (reading 'toLowerCase')"
}

It's my request, to use sons2mqtt with tts.

tsoybe commented 1 year ago

same error, if I use: svrooij/sonos-tts-polly:beta

svrooij commented 1 year ago

Since it does generate the voice list it does work, nothing wrong with the docker image.

Can you send your configuration without keys, validate the folder exists, then I'll have a try what's wrong

tsoybe commented 1 year ago

I'm using: docker run --env-file tts_env -p 5601:5601 svrooij/sonos-tts-polly

Content of tts_env:

SONOS_TTS_AMAZON_KEY=A...
SONOS_TTS_AMAZON_SECRET=z...
SONOS_TTS_AMAZON_REGION=eu-west-1
SONOS_TTS_ALLOW_GET=true

Which folder should be exists?

svrooij commented 1 year ago

You need to map a folder to the container. And set the location inside the container with the environment variable from the sample documentation.

This folder is used to save the mp3 files, so you don't need to generate the same tts file twice

tsoybe commented 1 year ago

Next try:

mkdir tts_cache
docker run --env-file tts_env -v ./tts_cache:/cache -p 5601:5601 ghcr.io/svrooij/node-sonos-tts-polly:latest

with tts_env:

SONOS_TTS_AMAZON_KEY=A...
SONOS_TTS_AMAZON_SECRET=z...
SONOS_TTS_AMAZON_REGION=eu-west-1
SONOS_TTS_ALLOW_GET=true
SONOS_TTS_CACHE_FOLDER=/cache

I validated inside the container, that the folder /cache is writable for User node .

The result: same error