If you are unable to use text to speech, here is a process using python to create an audio file compatible with WebEx Contact Center

The script creates an audio file with the exact telephony specifications required by WebEx Contact Center:

  • Format: .wav (Waveform Audio File Format)
  • Sample Rate: 8000 Hz (8 kHz)
  • Channels: 1 (Mono)
  • Audio Codec / Encoding: pcm_mulaw (G.711 μ-law, 8-bit) [1, 2, 3, 4]

In your terminal

  • pip install edge-tts ffmpeg-python
  • winget install -e –id Gyan.FFmpeg

Important – After install, close your terminal, CD back to the directory and run python script.py

import asyncio
import edge_tts
import ffmpeg
# 1. Define your configuration
TEXT_PROMPT = "Thank you for calling our support center. Please hold while we connect you."
OUTPUT_FILENAME = "webex_prompt.wav"
VOICE = "en-US-AvaNeural" # High-quality natural English voice
async def text_to_webex_audio():
temp_mp3 = "temp_voice.mp3"
print("Generating neural text-to-speech...")
communicate = edge_tts.Communicate(TEXT_PROMPT, VOICE)
await communicate.save(temp_mp3)
print("Converting to Webex specifications (8kHz, Mono, 8-bit u-law)...")
try:
(
ffmpeg
.input(temp_mp3)
.output(
OUTPUT_FILENAME,
ar='8000', # Sample Rate: 8kHz
ac=1, # Channels: Mono
acodec='pcm_mulaw' # Encoding: u-law / G.711
)
.overwrite_output()
.run(capture_stdout=True, capture_stderr=True)
)
print(f"Success! '{OUTPUT_FILENAME}' is ready to upload.")
except ffmpeg.Error as e:
print("FFmpeg Error:", e.stderr.decode())
# Run the process
asyncio.run(text_to_webex_audio())

Leave a Reply