Update app.py
Browse files
app.py
CHANGED
@@ -1919,57 +1919,77 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
1919 |
|
1920 |
submit_btn.click(complete_manual, [user_data, name_in, role_in, seniority_in, skills_in], [user_data, missing_section, interview_pre_section, pre_interview_greeting_md])
|
1921 |
|
1922 |
-
def
|
1923 |
-
|
1924 |
state = {
|
1925 |
-
"questions": [],
|
1926 |
-
"
|
1927 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1928 |
}
|
1929 |
-
|
1930 |
-
#
|
1931 |
context = ""
|
1932 |
prompt = build_interview_prompt(
|
1933 |
-
conversation_history=[],
|
1934 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1935 |
)
|
|
|
|
|
1936 |
first_q = groq_llm.predict(prompt)
|
1937 |
-
q_eval = {
|
1938 |
-
|
|
|
|
|
|
|
|
|
1939 |
state["questions"].append(first_q)
|
1940 |
state["question_evaluations"].append(q_eval)
|
1941 |
state["conversation_history"].append({'role': 'Interviewer', 'content': first_q})
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
start_interview_final_btn.click(
|
1968 |
-
|
1969 |
-
[user_data],
|
1970 |
-
[interview_state,
|
1971 |
)
|
1972 |
|
|
|
1973 |
def transcribe(audio_path):
|
1974 |
return whisper_stt(audio_path)
|
1975 |
|
|
|
1919 |
|
1920 |
submit_btn.click(complete_manual, [user_data, name_in, role_in, seniority_in, skills_in], [user_data, missing_section, interview_pre_section, pre_interview_greeting_md])
|
1921 |
|
1922 |
+
def start_interview(data):
|
1923 |
+
# Initialize interview state
|
1924 |
state = {
|
1925 |
+
"questions": [],
|
1926 |
+
"answers": [],
|
1927 |
+
"timings": [],
|
1928 |
+
"question_evaluations": [],
|
1929 |
+
"answer_evaluations": [],
|
1930 |
+
"conversation_history": [],
|
1931 |
+
"difficulty_adjustment": None,
|
1932 |
+
"question_idx": 0,
|
1933 |
+
"max_questions": 3,
|
1934 |
+
"q_start_time": time.time(),
|
1935 |
+
"log": []
|
1936 |
}
|
1937 |
+
|
1938 |
+
# Build prompt for first question
|
1939 |
context = ""
|
1940 |
prompt = build_interview_prompt(
|
1941 |
+
conversation_history=[],
|
1942 |
+
user_response="",
|
1943 |
+
context=context,
|
1944 |
+
job_role=data["job_role"],
|
1945 |
+
skills=data["skills"],
|
1946 |
+
seniority=data["seniority"],
|
1947 |
+
difficulty_adjustment=None,
|
1948 |
+
voice_label="neutral"
|
1949 |
)
|
1950 |
+
|
1951 |
+
# Generate first question
|
1952 |
first_q = groq_llm.predict(prompt)
|
1953 |
+
q_eval = {
|
1954 |
+
"Score": "N/A",
|
1955 |
+
"Reasoning": "Skipped to reduce processing time",
|
1956 |
+
"Improvements": []
|
1957 |
+
}
|
1958 |
+
|
1959 |
state["questions"].append(first_q)
|
1960 |
state["question_evaluations"].append(q_eval)
|
1961 |
state["conversation_history"].append({'role': 'Interviewer', 'content': first_q})
|
1962 |
+
|
1963 |
+
# Generate audio with Bark (wait for it)
|
1964 |
+
start = time.perf_counter()
|
1965 |
+
audio_future = bark_tts_async(first_q)
|
1966 |
+
audio_path = audio_future.result()
|
1967 |
+
print("⏱️ Bark TTS took", round(time.perf_counter() - start, 2), "seconds")
|
1968 |
+
|
1969 |
+
# Log question
|
1970 |
+
state["log"].append({
|
1971 |
+
"type": "question",
|
1972 |
+
"question": first_q,
|
1973 |
+
"question_eval": q_eval,
|
1974 |
+
"timestamp": time.time()
|
1975 |
+
})
|
1976 |
+
|
1977 |
+
return (
|
1978 |
+
state,
|
1979 |
+
gr.update(visible=False), # Hide interview_pre_section
|
1980 |
+
gr.update(visible=True), # Show interview_section
|
1981 |
+
audio_path, # Set audio
|
1982 |
+
f"*Question 1:* {first_q}" # Set question text
|
1983 |
+
)
|
1984 |
+
|
1985 |
+
# Hook into Gradio
|
|
|
1986 |
start_interview_final_btn.click(
|
1987 |
+
start_interview,
|
1988 |
+
[user_data],
|
1989 |
+
[interview_state, interview_pre_section, interview_section, question_audio, question_text]
|
1990 |
)
|
1991 |
|
1992 |
+
|
1993 |
def transcribe(audio_path):
|
1994 |
return whisper_stt(audio_path)
|
1995 |
|