Hello everyone…lately, integrating services like Google’s API for STT, Amazon’s for TTS and so on, I realized how ugly those seconds of absolute silence between one iteration and the next are. So I looked for an audio with the classic buzz of an office at work, to be able to put as a continuous background, to make the phone call more natural. I thought it was something relatively simple to obtain, but I didn’t succeed. I asked ChatGPT, Claude, looked on the forum… little information and most of it incomplete… and not that it’s not a useless topic, I think it’s one of those things suitable for making an “artificial” system, like an automatic pbx, more human. If anyone has a complete working example to share…Thanks
Hmm… Allison saying “one moment please” comes to mind…
Hi @simone686,
I am configuring my dial plan and facing the same problem as you, I want to add background noise to the dial background, because silence during calls doesn’t seem really natural. If you have any way or solution to do it, please share the solution, I really appreciate it.
The following code works for now…
I haven’t investigated further for now, but I noticed that it works for the first two calls…as if the file was running in the background and had to finish before restoring one of the two available slots…if you need a couple of audio files with office noise write me your email privately and I’ll send them to you
if you have any improvements let me know…
exten => s,1,NoOp()
same => n,Answer()
same => n,Playback(./silence/1)
same => n,Set(CURRENT_CHANNEL=${CHANNEL})
same => n,System(echo -e "Action: Login\nUsername: admin\nSecret: password\n\nAction: Originate\nChannel: Local/s@whisper-to-all\nApplication: Playback\nData: office\nSetVar: CHANNEL_TO_SPY=${CURRENT_CHANNEL}\n\nAction: Logoff\n" | nc 127.0.0.1 5038)
same => n,Playback(./silence/1)
same => n,Playback(sayprompt)
[whisper-to-all]
exten => s,1,Answer()
same => n,Playback(./silence/1)
same => n,ChanSpy(${CHANNEL_TO_SPY},qw)
same => n,SoftHangup(${CHANNEL_TO_SPY})
same => n,Hangup()
Hi @simone686
From your reply, I have tried to do some thing and it worked.
This is the code from AMI (if you need) and dialplan, some variables you need to change to work properly.
$options = array(
"host" => "127.0.0.1",
"scheme" => "tcp://",
"port" => "5038",
"username" => "whisper",
"secret" => "1234",
"connect_timeout" => 10000,
"read_timeout" => 100000
);
$pamiClient = new AMIClient($options);
$pamiClient->open();
$loginCre = new LoginAction("whisper", "1234");
$pamiClient->send($loginCre);
$originateDial = new OriginateAction("Local/s@play-background");
$originateDial->setContext('play-background');
$originateDial->setExtension("s");
$originateDial->setPriority("1");
$originateDial->setAsync(true);
$originateDial->setVariable("CHANNEL_TO_SPY", $channel); // $channel: replace to spied channel
$originateDial->setApplication("Playback");
$originateDial->setData($soundData); // $soundData: path to sound file
$this->pagiClient->consoleLog("Start whisper to user");
$pamiClient->send($originateDial);
$pamiClient->close();
[play-background]
exten => s, 1, Answer()
same => n, ChanSpy(${CHANNEL_TO_SPY},Ew)
same => n, SoftHangup(${CHANNEL_TO_SPY})
But it still have a little problems, that when starting dial, background music not play immediately, ChanSpy plays caller number for a while before start the music.
Begin MixMonitor Recording SIP/2810-0000000f
== Manager 'whisper' logged on from 127.0.0.1
Start whisper to user
-- Called s@play-background
== Manager 'whisper' logged off from 127.0.0.1
-- Executing [s@play-background:1] Answer("Local/s@play-background-0000000e;2", "") in new stack
-- Local/s@play-background-0000000e;1 answered
> Launching Playback(/var/lib/asterisk/sounds/background_music/office11) on Local/s@play-background-0000000e;1
-- <Local/s@play-background-0000000e;1> Playing '/var/lib/asterisk/sounds/background_music/office11.gsm' (language 'en')
-- Executing [s@play-background:2] ChanSpy("Local/s@play-background-0000000e;2", "SIP/2810,Ew") in new stack
-- <Local/s@play-background-0000000e;2> Playing 'beep.gsm' (language 'en')
Go to action: Play Prompt
Action: Play Prompt | Prompt: Something
-- AGI Script Executing Application: (Playback) Options: (/var/spool/asterisk/recording/1000/TextToSpeech/44bc062a)
-- <SIP/2810-0000000f> Playing '/var/spool/asterisk/recording/1000/TextToSpeech/44bc062a.slin' (language 'en')
**-- <Local/s@play-background-0000000e;2> Playing 'spy-sip.gsm' (language 'en')**
** -- <Local/s@play-background-0000000e;2> Playing 'digits/2.gsm' (language 'en')**
** -- <Local/s@play-background-0000000e;2> Playing 'digits/8.gsm' (language 'en')**
** -- <Local/s@play-background-0000000e;2> Playing 'digits/1.gsm' (language 'en')**
** -- <Local/s@play-background-0000000e;2> Playing 'digits/0.gsm' (language 'en')**
== Spying on channel SIP/2810-0000000f
-- Attaching spy channel Local/s@play-background-0000000e;2 to SIP/2810-0000000f
-- Attaching spy channel Local/s@play-background-0000000e;2 to SIP/2810-0000000f
Are you have any idea for it?
To prevent ChanSpy from announcing the channel and playing extension numbers, you need to use the q (quiet) option in ChanSpy’s options. This option suppresses ChanSpy’s initial and final announcements, allowing the background music to start immediately.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.