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

exotel example with jittery audio #747

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajay-ranga
Copy link

Please describe the changes in your PR. If it is addressing an issue, please reference that as well.

@ajay-ranga
Copy link
Author

async convertToExotelWavFormat(inputBuffer) {
    const tmpDir = os.tmpdir();
    const inputFile = path.join(tmpDir, `input${Date.now()}.pcm`);
    const outputFile = path.join(tmpDir, `output_${Date.now()}.wav`);

    try {
      await fs.writeFile(inputFile, inputBuffer);
      await new Promise((resolve, reject) => {
        const command = `ffmpeg -y -f s16le -ar 16000 -ac 1 -i "${inputFile}" -ar 8000 -ac 1 -sample_fmt s16 "${outputFile}"`;
        exec(command, (error, stdout, stderr) => {
          if (error) {
            console.error('Error in audio conversion with ffmpeg:', stderr);
            reject(error);
          } else {
            resolve();
          }
        });
      });

      return outputFile;
    } catch (err) {
      console.error('Error in audio file handling:', err);
      throw err;
    } finally {
      try {
        await fs.unlink(inputFile);
      } catch (cleanupErr) {
        console.error('Error cleaning up temporary PCM file:', cleanupErr);
      }
    }
  }
}

exotel provides us this method to get the audio working in desired format.

@jonnyjohnson1
Copy link

What did the "jittery audio" sound like? I'm getting some weird staticky noise coming back from eleven labs over a websocket connection with the pcm_16000 setting.

Is that what you had to fix with this pull request in Exotel?

@ajay-ranga
Copy link
Author

Currently there is this audio coming from this setup when used with Exotel.

https://drive.google.com/file/d/1mxfr_5TBsrZzdwBpzuavgl2FdwmbrtY8/view?usp=sharing

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

Successfully merging this pull request may close these issues.

2 participants