语音识别在python中的响应太慢

时间:2020-04-04 05:57:47

标签: python python-3.x speech-recognition

运行以下代码后,需要花费3分钟以上的时间才能打印出我所说的输入语句

mongos> use test
switched to db test
mongos> for (var i = 1; i <= 100000; i++) db.ranged.save({"age": NumberInt(i % 100), "createTime": new Date()});
WriteResult({ "nInserted" : 1 })
mongos> sh.status()
--- Sharding Status ---
  sharding version: {
        "_id" : 1,
        "minCompatibleVersion" : 5,
        "currentVersion" : 6,
        "clusterId" : ObjectId("5e8804c5bdf39b10a00d82cf")
  }
  shards:
        {  "_id" : "shard1",  "host" : "shard1/10.251.1.231:27018,10.251.1.232:27018",  "state" : 1 }
        {  "_id" : "shard2",  "host" : "shard2/10.251.1.232:27019,10.251.1.233:27019",  "state" : 1 }
        {  "_id" : "shard3",  "host" : "shard3/10.251.1.231:27020,10.251.1.233:27020",  "state" : 1 }
  active mongoses:
        "4.2.5" : 1
  autosplit:
        Currently enabled: yes
  balancer:
        Currently enabled:  yes
        Currently running:  no
        Failed balancer rounds in last 5 attempts:  0
        Migration Results for the last 24 hours:
                7 : Success
  databases:
        {  "_id" : "config",  "primary" : "config",  "partitioned" : true }
                config.system.sessions
                        shard key: { "_id" : 1 }
                        unique: false
                        balancing: true
                        chunks:
                                shard1  1
                        { "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : shard1 Timestamp(1, 0)
        {  "_id" : "test",  "primary" : "shard1",  "partitioned" : true,  "version" : {  "uuid" : UUID("6ed79961-a6c3-46c8-bbbe-dba074d782f5"),  "lastMod" : 1 } }
                test.ranged
                        shard key: { "age" : 1 }
                        unique: false
                        balancing: true
                        chunks:
                                shard1  1
                                shard2  2
                                shard3  2
                        { "age" : { "$minKey" : 1 } } -->> { "age" : 0 } on : shard2 Timestamp(2, 0)
                        { "age" : 0 } -->> { "age" : 44 } on : shard2 Timestamp(4, 0)
                        { "age" : 44 } -->> { "age" : 88 } on : shard3 Timestamp(4, 1)
                        { "age" : 88 } -->> { "age" : 99 } on : shard3 Timestamp(3, 4)
                        { "age" : 99 } -->> { "age" : { "$maxKey" : 1 } } on : shard1 Timestamp(3, 1)

mongos>

2 个答案:

答案 0 :(得分:1)

可能是您的互联网连接或您的麦克风,我在具有语音识别功能的对象中工作,但响应有时会花费10秒钟多一点

答案 1 :(得分:0)

这是我的一个例子,我雇了一个覆盆子

import speech_recognition as sr
#import robby
r = sr.Recognizer()
def inicio():
    with sr.Microphone() as source:
        print("Di algo:")
        audio = r.listen(source)
        funciones(audio)

def funciones(audio):
    try:
        print("Dijiste " + r.recognize_google(audio))
        if r.recognize_google(audio)=='hello':
            print('hello ')
            #robby.arranca()
            #inicio()
        elif r.recognize_google(audio)=='stop':
            robby.stop()
    except sr.UnknownValueError:
        print("Could not understand audio")
    except sr.RequestError as e:
        print("Could not request results; {0}".format(e))



inicio()