Spaces:
Sleeping
Sleeping
Download utils.py from Sabir55/DrugSearch_and_MedGuide: direct link, hf CLI and curl.
- Browser
- Download file 521 Bytes
-
https://huggingface.co/spaces/Sabir55/DrugSearch_and_MedGuide/resolve/main/utils.py
- Command line
-
hf download hf://spaces/Sabir55/DrugSearch_and_MedGuide/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Sabir55/DrugSearch_and_MedGuide/resolve/main/utils.py
521 Bytes
| from PIL import Image | |
| import pytesseract | |
| import speech_recognition as sr | |
| def extract_text_from_image(uploaded_file): | |
| img = Image.open(uploaded_file) | |
| return pytesseract.image_to_string(img) | |
| def speech_to_text(): | |
| r = sr.Recognizer() | |
| with sr.Microphone() as source: | |
| audio = r.listen(source) | |
| try: | |
| return r.recognize_google(audio) | |
| except sr.UnknownValueError: | |
| return "Could not understand audio." | |
| except sr.RequestError: | |
| return "Speech recognition service error." | |