2
私はPythonスクリプトを作成していくつかのタスクを実行しました。 私はこのスクリプトをPythonコンパイルで実行すると、魅力的に機能します。アスタリスクはPythonでagiスクリプトを実行できません
python test.py
しかし、私がAsterisk agiからtest.pyを呼び出すと、タイムスタンプを取得できません。 test.pyを実行したときに
exten => 201,n,agi(test.py,"おはようございます")
test.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
from datetime import datetime
import time
import sys
#from asterisk.agi import *
#agi = AGI()
#agi.verbose("python agi started")
#agi.verbose("params : " +agi.env['agi_arg_1'])
open_jtalk = ['open_jtalk']
mech = ['-x', '/home/linuxbrew/.linuxbrew/Cellar/open-jtalk/1.10_1/dic']
htsvoice = ['-m', '/home/linuxbrew/.linuxbrew/Cellar/open-jtalk/1.10_1/voice/mei/mei_normal.htsvoice']
speed = ['-r', '1.0']
print "nothing to lose"
timestamp = int(round(time.time() * 1000))
print "time : " + timestamp
file_name = 'tts_output' + str(timestamp) + '.wav'
file_name_output = 'tts_output' + str(timestamp) + '_8000.wav'
outwav = ['-ow', '/var/lib/asterisk/agi-bin/' + file_name]
cmd = open_jtalk + mech + htsvoice + speed + outwav
print "cmd : "
c = subprocess.Popen(cmd, stdin=subprocess.PIPE)
c.stdin.write("おはようございます")
c.stdin.close()
c.wait()
print "AAAAAAA"
#agi.verbose("command line is completed")
sox = ['sox']
samplerate = ['-r', '8000']
file_input = [file_name]
file_output = [file_name_output]
sox_command = sox + file_input + samplerate + file_output
ds = subprocess.Popen(sox_command)
ds.wait()
、コンソールは "失うものは何も" 印刷されていないが、次のコマンドをexcuteすることはできません。
timestamp = int(round(time.time() * 1000))
誰かが私を助けることができますか?どんな助けでも大歓迎です!
は、ファイルを実行可能です試してみてください? 'test.py'と同じように実行できるはずです。 – miken32
最後に私の脚本を書き留めることができます。私の問題は、rootとしてtest.pyを実行していることです(アスタリスクがルートとして実行されているため)。別のユーザーとしてアスタリスクを実行しようとしましたが、スクリプトはチャームのように動作します:) – nguoitotkhomaisao