Why local mp3 file is not playable in asterisk AGI?

I am trying to play a locally saved mp3 file which is generated by other audio software.
When I play an mp3 file which is created by asterisk it can play.

COMMAND: STREAM FILE /home/mtech/Documents/data/city question.mp3 "" 0
<PJSIP/1101-0000003d>AGI Rx << STREAM FILE /home/mtech/Documents/data/city question.mp3 "" 0
<PJSIP/1101-0000003d>AGI Tx >> 520-Invalid command syntax.  Proper usage follows:
    RESULT_LINE: 520-Invalid command syntax.  Proper usage follows:
<PJSIP/1101-0000003d>AGI Tx >> Send the given file, allowing playback to be interrupted by the given digits, if any. Returns <literal>0</literal> if playback completes without a digit being pressed, or the ASCII numerical value of the digit if one was pressed, or <literal>-1</literal> on error or if the channel was disconnected. If musiconhold is playing before calling stream file it will be automatically stopped and will not be restarted after completion.
It sets the following channel variables upon completion:
<variable>PLAYBACKSTATUS</variable>: The status of the playback attempt as a text string.
    <value>SUCCESS</value>
    <value>FAILED</value>
Traceback (most recent call last):
<PJSIP/1101-0000003d>AGI Tx >> 520 End of proper usage.
  File "/var/lib/asterisk/agi-bin/agiUpdate.py", line 130, in <module>
    run()
  File "/var/lib/asterisk/agi-bin/agiUpdate.py", line 105, in run
    output_dialogflow = googleDialogflow(output_googleSTT)
  File "/var/lib/asterisk/agi-bin/agiUpdate.py", line 58, in googleDialogflow
    agi.stream_file('/home/mtech/Documents/data/city question.mp3')
  File "/home/mtech/anaconda3/lib/python3.8/site-packages/asterisk/agi.py", line 283, in stream_file
    response = self.execute(
  File "/home/mtech/anaconda3/lib/python3.8/site-packages/asterisk/agi.py", line 150, in execute
    return self.get_result()
  File "/home/mtech/anaconda3/lib/python3.8/site-packages/asterisk/agi.py", line 209, in get_result
    raise AGIUsageError(usage)
asterisk.agi.AGIUsageError: 520-Invalid command syntax.  Proper usage follows:
Send the given file, allowing playback to be interrupted by the given digits, if any. Returns <literal>0</literal> if playback completes without a digit being pressed, or the ASCII numerical value of the digit if one was pressed, or <literal>-1</literal> on error or if the channel was disconnected. If musiconhold is playing before calling stream file it will be automatically stopped and will not be restarted after completion.
It sets the following channel variables upon completion:
<variable>PLAYBACKSTATUS</variable>: The status of the playback attempt as a text string.
<value>SUCCESS</value>
<value>FAILED</value>
520 End of proper usage.

    -- <PJSIP/1101-0000003d>AGI Script agiUpdate.py completed, returning 0
    -- Executing [1104@Long-Distance:3] Hangup("PJSIP/1101-0000003d", "") in new stack
  == Spawn extension (Long-Distance, 1104, 3) exited non-zero on 'PJSIP/1101-0000003d'

Because there is a space in the name?

If you read the error message, the issue is not with the file, it’s with your AGI command. Doesn’t your AGI library automagically enclose the file name in quotes?

You may also need to drop the file type.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.