- 参考文档:https://picovoice.ai/docs/quick-start/porcupine-python/
配置
pip install pvporcupine
主代码
ACCESS_KEY
:需要将该参数填入即可
#
# Copyright 2018-2023 Picovoice Inc.
#
# You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
# file accompanying this source.
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
import argparse
import os
import struct
import wave
from datetime import datetime
import pvporcupine
from pvrecorder import PvRecorder
# ##################################################### #
ACCESS_KEY = 'xxxx' # 更换成自己的
# ##################################################### #
# pvporcupine.KEYWORDS
print(f"Keywords: {pvporcupine.KEYWORDS}")
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--access_key',
default=ACCESS_KEY,
help='AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)')
parser.add_argument(
'--keywords',
nargs='+',
help='List of default keywords for detection. Available keywords: %s' % ', '.join(
'%s' % w for w in sorted(pvporcupine.KEYWORDS)),
# choices=sorted(pvporcupine.KEYWORDS),
default=[