Closed archie-ai-code-explain-pr-review[bot] closed 1 month ago
Install streamlit-audio-recorder
Library
pip install streamlit-audio-recorder
Update ReviewRequest
and SelfReviewRequest
Models
audio_review
field to both models in review.py
and self_review.py
.
class ReviewRequest(BaseModel):
your_role: str
candidate_role: str
perf_question: Optional[str] = None
your_review: str
audio_review: Optional[bytes] = None # New field
llm_type: str
user_api_key: str
model_size: str = "small"
class SelfReviewRequest(BaseModel):
text_dump: str
questions: List[str]
instructions: Optional[str] = None
audio_review: Optional[bytes] = None # New field
llm_type: str
user_api_key: str
model_size: str = "medium"
Add Audio Recorder to Streamlit UI in app.py
from streamlit_audio_recorder import audio_recorder
audio_review = audio_recorder()
Implement convert_speech_to_text
Function in llm.py
def convert_speech_to_text(audio_data: bytes) -> str:
from groq import Whisper
whisper = Whisper(api_key=GROQ_API_KEY)
return whisper.transcribe(audio_data)
Update Review Generation Logic in app.py
generate_review
and generate_self_review
calls to handle audio_review
.
if audio_review:
your_review = convert_speech_to_text(audio_review)
ReviewRequest
or SelfReviewRequest
objects./app.py /self_review.py /review.py /llm.py
streamlit-audio-recorder
library to enable audio recording in the appconvert_speech_to_text
function using the Whisper model on the Groq library to convert the audio to textReviewRequest
andSelfReviewRequest
models to include an optionalaudio_review
field, and use this input for generating the review and self-review