question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

what's the best practice to write a parser for speech recognition results ?

See original GitHub issue

i want to create a smiple parser for speech recognition results ,the grammar going to be complex that’s why i want some advices about how to deal with complex grammar . i have this simple example below using speech recognition api and lark parser :

from lark import Lark,Token, Transformer, v_args
from helpers.file_process import FileProcess
import numpy as np

speech_grammar = """
start              : KEY TYPE FNAME PATH?
KEY                : "create" | "delete" | "open" | "read" | "make" 
TYPE               : "file" | "folder" 
FNAME              : (/[a-z]/)+ 
PATH               : (/[a-zA-Z]/)+":"(/[\\/]/)+DIRNAME
DIRNAME            : ((/[a-zA-Z0-9]/)+(/[\\/]/)?)*

%ignore (" ")+
"""

speech_parser = Lark(speech_grammar)

def run(input):
    try:
        speech = speech_parser.parse(input)
        instr=np.array(speech.children)
        return FileProcess(instr).request_process()
    except Exception as err :
        return err

def main(input):
    return run(input)

def test():
    print(run("make file test d:/test"))
    print(run("delete file test"))

i will add more terminals (Vt) in the grammar part , any suggestions or advices would be much appreciated ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
erezshcommented, Feb 24, 2021

It sounds like you’re asking about the lingual interface, rather than parsing.

Maybe if you provide some examples of the output you’re getting (or hoping to get) from the voice API, we can tell you how to parse it.

I would suggest considering a “DSL” for the paths that’s more natural for speaking, like “drive d folder myfolder”

0reactions
Morojscommented, Feb 24, 2021

the grammar describe how users interact with speech api , we can’t use “create file test d:/myfolder” like that because the api doesn’t understand the path and it doesn’t have the concatenation between each path item, is there any way to make it easier to understand and use for speech api?

Read more comments on GitHub >

github_iconTop Results From Across the Web

All About Parsing: What it is, and how it relates to Text-to ...
At its basest definition, 'parsing' is “to analyze (a sentence, in this case) in terms of grammatical constituents, identifying the parts of speech, ......
Read more >
The Ultimate Guide To Speech Recognition With Python
An in-depth tutorial on speech recognition with Python. Learn which speech recognition library gives the best results and build a full-featured "Guess The ......
Read more >
SRGS Best Practices | LumenVox Knowledgebase
Any input to a grammar should only have one valid parse (the Grammar Editor tool, included with the LumenVox Speech Tuner, can show...
Read more >
A Guide To Parsing: Algorithms And Terminology
An in-depth coverage of parsing terminology an issues, together with an explanation for each one of the major algorithms and when to use...
Read more >
An Analysis of Using Semantic Parsing for Speech Recognition
This thesis explores the use of semantic parsing for improving speech recognition performance. Specifically, it explores how a semantic parser may be used ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found