ianhajra / virtual_assistant

This repository houses the code for running a local virtual assistant. It is still under development.
MIT License
5 stars 0 forks source link

Speech_recognition outputs words such as "degrees" or "percent" as the symbols such as "°" or "%" #73

Open chungjryan opened 3 weeks ago

chungjryan commented 3 weeks ago

I think we should figure out how to make it such that output is only words and no symbols are allowed. Lets look into the Speech_recognition documentation and hope theres a toggle there because otherwise we're gonna have one hell of a switch case statement.

Discovered issue in #30, in tests/nlp_tests/test_stt_use_cases buggy output is commented

ianhajra commented 3 weeks ago

To my knowledge, this is isn't a thing.

Likely, we can just add something like this to our nlp library:

def replace_symbols_with_words(text):
    replacements = {
        '%': 'percent',
        '&': 'and',
        '$': 'dollar',
        '@': 'at',
        # etc.
    }

    for symbol, word in replacements.items():
        text = text.replace(symbol, word)

    return text

This is easier than using a switch case, and although it's not the prettiest it will get the job done.

@chungjryan unless you are against me doing this, I will implement it and adjust test cases and process_text accordingly.

chungjryan commented 3 weeks ago

@ianhajra naw ur good