【发布时间】:2021-08-25 07:51:42
【问题描述】:
我在 google 中有典型的 speech_recognition,它在我的服务器上的命令行 python 3 -- Python 3.7.3(默认,2020 年 7 月 25 日,13:03:44)[GCC 8.3.0] 在 Linux 上正常工作。
在命令行中运行良好,例如:
>>> import speech_recognition as sr
>>> r = sr.Recognizer()
>>> with sr.AudioFile('/var/boot/pcm.wav') as source:
... a=r.record(source)
... tt=r.recognize_google(a)
... print(tt)
...
therapy in motion giving challenge
>>>
但我需要在 Postgres 函数 plpython3u 中运行它,对于另一种情况 plpython3u 运行良好,例如 Polly AWS python 版本应用程序。
我不工作的代码是:
CREATE OR REPLACE FUNCTION ivr.boot_action1_pyhon(name_file character varying)
RETURNS character varying
LANGUAGE plpython3u
AS $function$
import speech_recognition as sr
r = sr.Recognizer()
with sr.AudioFile('/var/boot/pcm.wav') as source:
a=r.record(source)
tt=r.recognize_google(a)
print(tt)
return tt
$function$
;
结果问题是:
SQL Error [38000]: BŁĄD: AttributeError: 'NoneType' object has no attribute 'split'
Gdzie: Traceback (most recent call last):
PL/Python function "boot_action1_pyhon", line 7, in <module>
tt=r.recognize_google(a)
PL/Python function "boot_action1_pyhon", line 827, in recognize_google
PL/Python function "boot_action1_pyhon", line 444, in get_flac_data
PL/Python function "boot_action1_pyhon", line 1182, in get_flac_converter
PL/Python function "boot_action1_pyhon", line 1216, in shutil_which
funkcja PL/Python "boot_action1_pyhon"
【问题讨论】:
标签: python postgresql speech-recognition wav