Spaces:
Runtime error
Runtime error
Update voice.py
Browse files
voice.py
CHANGED
|
@@ -6,6 +6,7 @@ import speech_recognition as sr
|
|
| 6 |
from gtts import gTTS
|
| 7 |
from pydub import AudioSegment
|
| 8 |
import base64
|
|
|
|
| 9 |
|
| 10 |
def recognize_speech(audio_data: bytes, language: str = "en-US") -> str:
|
| 11 |
recognizer = sr.Recognizer()
|
|
@@ -43,7 +44,7 @@ def extract_text_from_pdf(pdf_data: bytes) -> str:
|
|
| 43 |
text = ""
|
| 44 |
for page in pdf_reader.pages:
|
| 45 |
text += page.extract_text() or ""
|
| 46 |
-
return clean_text_response(text)
|
| 47 |
except Exception as e:
|
| 48 |
logger.error(f"Error extracting text from PDF: {e}")
|
| 49 |
raise HTTPException(status_code=400, detail="Failed to extract text from PDF")
|
|
|
|
| 6 |
from gtts import gTTS
|
| 7 |
from pydub import AudioSegment
|
| 8 |
import base64
|
| 9 |
+
from utils import clean_text_response # Added this import
|
| 10 |
|
| 11 |
def recognize_speech(audio_data: bytes, language: str = "en-US") -> str:
|
| 12 |
recognizer = sr.Recognizer()
|
|
|
|
| 44 |
text = ""
|
| 45 |
for page in pdf_reader.pages:
|
| 46 |
text += page.extract_text() or ""
|
| 47 |
+
return clean_text_response(text) # Now works with the import
|
| 48 |
except Exception as e:
|
| 49 |
logger.error(f"Error extracting text from PDF: {e}")
|
| 50 |
raise HTTPException(status_code=400, detail="Failed to extract text from PDF")
|