LeonardSEO / MMM-VoiceCompanion

A voice-activated assistant module for MagicMirror² using OpenAI's Whisper for speech recognition and GPT for natural language processing. This module allows users to interact with their MagicMirror using voice commands, enhancing the smart mirror experience with AI-powered conversations and information retrieval.
MIT License
3 stars 1 forks source link

Error processing audio: BadRequestError: 400 Invalid file format. #4

Open gazambuja opened 1 week ago

gazambuja commented 1 week ago

After update to the last version, this is happening:

[2024-09-11 11:50:40.019] [LOG]   MMM-VoiceCompanion: Still listening for wake word... 
[2024-09-11 11:50:43.798] [INFO]  Wake word detected: COMPUTER 
[2024-09-11 11:50:43.828] [LOG]   Silence detected... 
[2024-09-11 11:50:44.376] [ERROR] Error processing audio: BadRequestError: 400 Invalid file format. Supported formats: ['flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm']
    at APIError.generate (/home/mirror/MagicMirror/modules/MMM-VoiceCompanion/node_modules/openai/error.js:45:20)
    at OpenAI.makeStatusError (/home/mirror/MagicMirror/modules/MMM-VoiceCompanion/node_modules/openai/core.js:275:33)
    at OpenAI.makeRequest (/home/mirror/MagicMirror/modules/MMM-VoiceCompanion/node_modules/openai/core.js:318:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Class.transcribeAudio (/home/mirror/MagicMirror/modules/MMM-VoiceCompanion/node_helper.js:162:31)
    at async Class.stopRecording (/home/mirror/MagicMirror/modules/MMM-VoiceCompanion/node_helper.js:143:35)
    at async Class.listenForWakeWord (/home/mirror/MagicMirror/modules/MMM-VoiceCompanion/node_helper.js:85:21) {
  status: 400,
  headers: {
    'access-control-expose-headers': 'X-Request-ID',
    'alt-svc': 'h3=":443"; ma=86400',
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '8c1878bafcx21e9e-EZE',
    connection: 'keep-alive',
    'content-length': '226',
    'content-type': 'application/json',
    date: 'Wed, 11 Sep 2024 14:50:42 GMT',
    'openai-organization': 'xxxx-xxxx',
    'openai-processing-ms': '26',
    'openai-version': '2020-10-01',
    server: 'cloudflare',
    'set-cookie': '__cf_bm=ExQPuoOxxZwB2_s0FOeZdN.2073ISivbUSqk6WwgyGg-1726066242-1.0.1.1-jlVfjWMBAWButof9.NAqCxxSMB3AYQG7VYc_hQRZk5G1OXH_5aSVmO9Yamv7wELGWdxxHN.4g1_Rv5B9mJoVA; path=/; expires=Wed, 11-Sep-24 15:20:42 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=1wh.5Y2xxNJ71C4pSR4oQUBaJvxxtDYTAF3LDZUr45ws-1726xx6242015-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None',
    'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
    'x-content-type-options': 'nosniff',
    'x-ratelimit-limit-requests': '100',
    'x-ratelimit-remaining-requests': '99',
    'x-ratelimit-reset-requests': '600ms',
    'x-request-id': 'req_7f78daxxxbc4d70688d1bba843f65d2d'
  },
  request_id: 'req_7f78daxxxbc4d70688d1bba843f65d2d',
  error: {
    message: "Invalid file format. Supported formats: ['flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm']",
    type: 'invalid_request_error',
    param: null,
    code: null
  },
  code: null,
  param: null,
  type: 'invalid_request_error'
} 

My configuration:

{
    module: "MMM-VoiceCompanion",
    disabled: false,
    config: {
        wakeWord: "COMPUTER", // of een andere ondersteunde BuiltinKeyword
        porcupineAccessKey: "xxxxx",
        openAiKey: "xxxxx",
        voiceId: "echo", // of een andere ondersteunde stem-id
        language: "en",
        conversationTimeout: 120000, // 2 minuten
        standbyTimeout: 30000, // 30 seconden
        audioDeviceIndex: 1,  // Set this to the index of your preferred audio input device
        silenceThreshold: 2,  // Adjust this value to fine-tune silence detection
        silenceDuration: 60,  // Number of frames of silence to trigger stop recording
        debug: true
    }
},
gazambuja commented 6 days ago
ls /tmp/audio.wav -lh
-rw-rw-r-- 1 mirror mirror 0 Sep 11 12:08 /tmp/audio.wav

I try to change silenceDuration to 1000, but with the same result.