speech-to-speech
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
venv/
|
||||
@@ -0,0 +1,87 @@
|
||||
import speech_recognition as sr
|
||||
import pyttsx3
|
||||
import google.generativeai as genai
|
||||
import json
|
||||
|
||||
# 🔐 Configure Gemini API key
|
||||
genai.configure(api_key="AQ.Ab8RN6Ja_fjsA6xNxJLGPxCZJXfqmTdPzp-ATB5pAUveK7aoQw")
|
||||
model = genai.GenerativeModel("gemini-2.5-flash")
|
||||
|
||||
|
||||
# Loaded JSON File
|
||||
with open("property_data.json", "r") as f:
|
||||
property_data = json.load(f)
|
||||
|
||||
# Initialize TTS engine
|
||||
engine = pyttsx3.init()
|
||||
|
||||
# Voice choice
|
||||
print("Choose a voice:\n1. Male (David)\n2. Female (Zira)")
|
||||
choice = input("Enter 1 or 2: ")
|
||||
voices = engine.getProperty("voices")
|
||||
if choice == "1":
|
||||
for voice in voices:
|
||||
if "David" in voice.name:
|
||||
engine.setProperty("voice", voice.id)
|
||||
break
|
||||
elif choice == "2":
|
||||
for voice in voices:
|
||||
if "Zira" in voice.name:
|
||||
engine.setProperty("voice", voice.id)
|
||||
break
|
||||
|
||||
|
||||
# Speak Function
|
||||
def speak(text):
|
||||
engine.say(text)
|
||||
engine.runAndWait()
|
||||
|
||||
|
||||
# Listen Function
|
||||
def listen():
|
||||
r = sr.Recognizer()
|
||||
with sr.Microphone() as source:
|
||||
print("🎤 Speak now:")
|
||||
audio = r.listen(source)
|
||||
try:
|
||||
text = r.recognize_google(audio)
|
||||
print("🧑 You:", text)
|
||||
return text
|
||||
except sr.UnknownValueError:
|
||||
print("❌ Could not understand.")
|
||||
speak("Sorry, I didn't catch that.")
|
||||
return None
|
||||
|
||||
|
||||
# Ask Gemini with Property Data
|
||||
def ask_gemini_with_data(user_query, data):
|
||||
context = "You are a real estate assistant. Here are the property listings:\n"
|
||||
for p in data:
|
||||
context += (
|
||||
f"- {p['name']} in {p['location']} is a {p['type']} priced at {p['price']}"
|
||||
)
|
||||
prompt = context + f"\nUser question: {user_query}"
|
||||
|
||||
try:
|
||||
response = model.generate_content(prompt)
|
||||
return response.text
|
||||
except Exception as e:
|
||||
print("⚠️ Gemini Error:", e)
|
||||
return "Sorry, I couldn't process that request."
|
||||
|
||||
|
||||
# Loop
|
||||
while True:
|
||||
try:
|
||||
question = listen()
|
||||
if question:
|
||||
if "exit" in question.lower() or "stop" in question.lower():
|
||||
speak("Okay, goodbye!")
|
||||
break
|
||||
answer = ask_gemini_with_data(question, property_data)
|
||||
print("🤖 Gemini:", answer)
|
||||
speak(answer)
|
||||
except KeyboardInterrupt:
|
||||
print("Stopped.")
|
||||
speak("Goodbye!")
|
||||
break
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
# import json
|
||||
|
||||
# print("=" * 50)
|
||||
# print("AI MEDICAL EXAMINER ASSISTANT")
|
||||
# print("=" * 50)
|
||||
|
||||
# # Simulated transcript
|
||||
# transcript = input("\nEnter patient statement:\n> ")
|
||||
|
||||
# text = transcript.lower()
|
||||
|
||||
# detected_conditions = []
|
||||
# questions = []
|
||||
|
||||
# # Disease Question Bank
|
||||
# question_bank = {
|
||||
# "diabetes": [
|
||||
# "When were you diagnosed?",
|
||||
# "What is your current HbA1c?",
|
||||
# "Are you taking insulin?",
|
||||
# "Any kidney disease?",
|
||||
# "Any eye complications?"
|
||||
# ],
|
||||
# "hypertension": [
|
||||
# "Since when do you have hypertension?",
|
||||
# "Current BP readings?",
|
||||
# "Are you taking medication regularly?",
|
||||
# "Any heart disease?",
|
||||
# "Any stroke history?"
|
||||
# ],
|
||||
# "smoke": [
|
||||
# "How many cigarettes per day?",
|
||||
# "For how many years?",
|
||||
# "Current smoker or ex-smoker?",
|
||||
# "Any chronic cough?",
|
||||
# "Any COPD symptoms?"
|
||||
# ]
|
||||
# }
|
||||
|
||||
# # Detect conditions
|
||||
# if "diabetes" in text:
|
||||
# detected_conditions.append("Diabetes")
|
||||
# questions.extend(question_bank["diabetes"])
|
||||
|
||||
# if "hypertension" in text or "bp" in text:
|
||||
# detected_conditions.append("Hypertension")
|
||||
# questions.extend(question_bank["hypertension"])
|
||||
|
||||
# if "smoke" in text or "smoking" in text:
|
||||
# detected_conditions.append("Smoking")
|
||||
# questions.extend(question_bank["smoke"])
|
||||
|
||||
# print("\nDetected Conditions:")
|
||||
# for condition in detected_conditions:
|
||||
# print(f"✓ {condition}")
|
||||
|
||||
# if not detected_conditions:
|
||||
# print("No predefined condition detected.")
|
||||
# exit()
|
||||
|
||||
# print("\nSuggested Follow-Up Questions:")
|
||||
# for i, q in enumerate(questions, start=1):
|
||||
# print(f"{i}. {q}")
|
||||
|
||||
# # Collect answers
|
||||
# answers = {}
|
||||
|
||||
# print("\nEnter Patient Answers:")
|
||||
# for q in questions:
|
||||
# answers[q] = input(f"{q} : ")
|
||||
|
||||
# # Generate summary
|
||||
# print("\n" + "=" * 50)
|
||||
# print("FINAL MEDICAL SUMMARY")
|
||||
# print("=" * 50)
|
||||
|
||||
# print("\nPatient Statement:")
|
||||
# print(transcript)
|
||||
|
||||
# print("\nDetected Conditions:")
|
||||
# for condition in detected_conditions:
|
||||
# print(f"- {condition}")
|
||||
|
||||
# print("\nResponses:")
|
||||
# for question, answer in answers.items():
|
||||
# print(f"- {question}: {answer}")
|
||||
|
||||
# print("\nMedical Completeness Score: 90%")
|
||||
# print("Contradiction Score: Low")
|
||||
# print("Additional Investigation: Recommended")
|
||||
|
||||
# print("\nAreas Requiring Review:")
|
||||
# for condition in detected_conditions:
|
||||
# print(f"- {condition}")
|
||||
|
||||
# print("\nReport Generated Successfully.")
|
||||
# print("=" * 50)
|
||||
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from elevenlabs.client import ElevenLabs
|
||||
|
||||
load_dotenv()
|
||||
|
||||
client = ElevenLabs(
|
||||
api_key=os.getenv("ELEVENLABS_API_KEY")
|
||||
)
|
||||
|
||||
print("=" * 60)
|
||||
print("AI MEDICAL EXAMINER ASSISTANT")
|
||||
print("=" * 60)
|
||||
|
||||
medical_questions = {
|
||||
"diabetes": [
|
||||
"When were you diagnosed?",
|
||||
"What medications are you taking?",
|
||||
"Do you use insulin?",
|
||||
"Any kidney disease?",
|
||||
"Any eye complications?"
|
||||
],
|
||||
"hypertension": [
|
||||
"Since when do you have hypertension?",
|
||||
"What is your current BP reading?",
|
||||
"Are you taking medications regularly?",
|
||||
"Any heart disease?",
|
||||
"Any stroke history?"
|
||||
],
|
||||
"smoking": [
|
||||
"How many cigarettes per day?",
|
||||
"For how many years have you smoked?",
|
||||
"Current smoker or ex-smoker?",
|
||||
"Any chronic cough?",
|
||||
"Any COPD symptoms?"
|
||||
]
|
||||
}
|
||||
|
||||
answers = {}
|
||||
|
||||
print("\nAI Doctor: Do you have diabetes? (yes/no)")
|
||||
diabetes = input("Patient: ").strip().lower()
|
||||
|
||||
if diabetes == "yes":
|
||||
answers["Condition"] = "Diabetes"
|
||||
|
||||
for question in medical_questions["diabetes"]:
|
||||
print(f"\nAI Doctor: {question}")
|
||||
response = input("Patient: ")
|
||||
answers[question] = response
|
||||
|
||||
print("\nAI Doctor: Do you have hypertension? (yes/no)")
|
||||
hypertension = input("Patient: ").strip().lower()
|
||||
|
||||
if hypertension == "yes":
|
||||
answers["Hypertension"] = "Yes"
|
||||
|
||||
for question in medical_questions["hypertension"]:
|
||||
print(f"\nAI Doctor: {question}")
|
||||
response = input("Patient: ")
|
||||
answers[question] = response
|
||||
|
||||
print("\nAI Doctor: Do you smoke? (yes/no)")
|
||||
smoking = input("Patient: ").strip().lower()
|
||||
|
||||
if smoking == "yes":
|
||||
answers["Smoking"] = "Yes"
|
||||
|
||||
for question in medical_questions["smoking"]:
|
||||
print(f"\nAI Doctor: {question}")
|
||||
response = input("Patient: ")
|
||||
answers[question] = response
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("FINAL MEDICAL REPORT")
|
||||
print("=" * 60)
|
||||
|
||||
for key, value in answers.items():
|
||||
print(f"{key}: {value}")
|
||||
|
||||
print("\nMedical Completeness Score: 95%")
|
||||
print("Contradiction Score: Low")
|
||||
print("Additional Investigation Recommended: Yes")
|
||||
|
||||
print("=" * 60)
|
||||
@@ -0,0 +1,4 @@
|
||||
FINAL MEDICAL REPORT
|
||||
============================================================
|
||||
|
||||
Diabetes:
|
||||
@@ -0,0 +1,182 @@
|
||||
[
|
||||
{
|
||||
"name": "Sunrise Villas",
|
||||
"location": "Pune",
|
||||
"type": "Villa",
|
||||
"price": "1.2 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Maple Heights",
|
||||
"location": "Mumbai",
|
||||
"type": "2BHK Apartment",
|
||||
"price": "85 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Ocean Residency",
|
||||
"location": "Goa",
|
||||
"type": "Beach House",
|
||||
"price": "2.5 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Skyline Towers",
|
||||
"location": "Bangalore",
|
||||
"type": "3BHK Apartment",
|
||||
"price": "1.05 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Green Acres",
|
||||
"location": "Hyderabad",
|
||||
"type": "Independent House",
|
||||
"price": "95 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Palm Meadows",
|
||||
"location": "Chennai",
|
||||
"type": "Luxury Villa",
|
||||
"price": "3 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Cityscape Heights",
|
||||
"location": "Delhi",
|
||||
"type": "Studio Apartment",
|
||||
"price": "45 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Lakeview Residences",
|
||||
"location": "Udaipur",
|
||||
"type": "Lakefront Villa",
|
||||
"price": "1.8 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Tech Park Homes",
|
||||
"location": "Noida",
|
||||
"type": "2BHK Apartment",
|
||||
"price": "70 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Royal Heritage",
|
||||
"location": "Jaipur",
|
||||
"type": "Heritage Villa",
|
||||
"price": "2.75 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Emerald Enclave",
|
||||
"location": "Ahmedabad",
|
||||
"type": "3BHK Apartment",
|
||||
"price": "1.2 Cr"
|
||||
},
|
||||
{
|
||||
"name": "The Urban Nest",
|
||||
"location": "Kolkata",
|
||||
"type": "2BHK Apartment",
|
||||
"price": "60 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Riverfront Meadows",
|
||||
"location": "Surat",
|
||||
"type": "Villa",
|
||||
"price": "1.4 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Hilltop Residency",
|
||||
"location": "Shimla",
|
||||
"type": "Cottage",
|
||||
"price": "1.1 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Blue Orchid Homes",
|
||||
"location": "Nagpur",
|
||||
"type": "4BHK Independent House",
|
||||
"price": "88 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Prestige Panorama",
|
||||
"location": "Chandigarh",
|
||||
"type": "Penthouse",
|
||||
"price": "2 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Golden Leaf Apartments",
|
||||
"location": "Indore",
|
||||
"type": "2BHK Apartment",
|
||||
"price": "52 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Whispering Woods",
|
||||
"location": "Dehradun",
|
||||
"type": "Cottage",
|
||||
"price": "93 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "City View Heights",
|
||||
"location": "Thane",
|
||||
"type": "3BHK Apartment",
|
||||
"price": "1.1 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Silver Sands Residency",
|
||||
"location": "Alibaug",
|
||||
"type": "Beach Villa",
|
||||
"price": "3.2 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Eco Green Apartments",
|
||||
"location": "Bhopal",
|
||||
"type": "2BHK Apartment",
|
||||
"price": "48 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Royal Gardenia",
|
||||
"location": "Mysore",
|
||||
"type": "3BHK Independent House",
|
||||
"price": "83 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Infinity Towers",
|
||||
"location": "Faridabad",
|
||||
"type": "High-rise Apartment",
|
||||
"price": "92 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Casa Del Sol",
|
||||
"location": "Pondicherry",
|
||||
"type": "Beach House",
|
||||
"price": "2.1 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Galaxy Heights",
|
||||
"location": "Lucknow",
|
||||
"type": "3BHK Apartment",
|
||||
"price": "74 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Green Field Residences",
|
||||
"location": "Rajkot",
|
||||
"type": "Row House",
|
||||
"price": "65 Lakhs"
|
||||
},
|
||||
{
|
||||
"name": "Pearl Regency",
|
||||
"location": "Jodhpur",
|
||||
"type": "Heritage Home",
|
||||
"price": "2 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Rainforest Retreat",
|
||||
"location": "Wayanad",
|
||||
"type": "Eco-Villa",
|
||||
"price": "1.3 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Sky High Residency",
|
||||
"location": "Goa",
|
||||
"type": "Penthouse",
|
||||
"price": "3.5 Cr"
|
||||
},
|
||||
{
|
||||
"name": "Palm Avenue",
|
||||
"location": "Goa",
|
||||
"type": "Villa",
|
||||
"price": "1.6 Cr"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"diabetes": [
|
||||
"When were you diagnosed?",
|
||||
"What medications are you taking?",
|
||||
"Do you use insulin?",
|
||||
"Any kidney disease?",
|
||||
"Any eye complications?"
|
||||
],
|
||||
"hypertension": [
|
||||
"Since when do you have hypertension?",
|
||||
"What is your current BP reading?",
|
||||
"Are you taking medications regularly?"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
speechrecognition
|
||||
pyttsx3
|
||||
google-generativeai
|
||||
pyaudio
|
||||
@@ -0,0 +1,244 @@
|
||||
# import json
|
||||
# import speech_recognition as sr
|
||||
# from elevenlabs.client import ElevenLabs
|
||||
# from elevenlabs.play import play
|
||||
|
||||
# # -----------------------
|
||||
# # ElevenLabs
|
||||
# # -----------------------
|
||||
|
||||
# client = ElevenLabs(
|
||||
# api_key="sk_a5001c59bb470cefd481dc0fbdc1f3b1e1b5e2dd057929ea"
|
||||
# )
|
||||
|
||||
# # -----------------------
|
||||
# # Voice Functions
|
||||
# # -----------------------
|
||||
|
||||
# def doctor_speak(text):
|
||||
# print(f"\nDoctor: {text}")
|
||||
|
||||
# audio = client.text_to_speech.convert(
|
||||
# text=text,
|
||||
# voice_id="JBFqnCBsd6RMkjVDRZzb",
|
||||
# model_id="eleven_multilingual_v2",
|
||||
# output_format="mp3_44100_128",
|
||||
# )
|
||||
|
||||
# play(audio)
|
||||
|
||||
|
||||
# def patient_listen():
|
||||
# recognizer = sr.Recognizer()
|
||||
|
||||
# with sr.Microphone() as source:
|
||||
# print("\n🎤 Speak now...")
|
||||
# recognizer.adjust_for_ambient_noise(source, duration=1)
|
||||
|
||||
# audio = recognizer.listen(source)
|
||||
|
||||
# try:
|
||||
# text = recognizer.recognize_google(audio)
|
||||
|
||||
# print(f"\nPatient: {text}")
|
||||
|
||||
# return text
|
||||
|
||||
# except Exception:
|
||||
# print("\nCould not understand speech")
|
||||
# return ""
|
||||
|
||||
|
||||
# # -----------------------
|
||||
# # Load Questions
|
||||
# # -----------------------
|
||||
|
||||
# with open("questions.json", "r") as f:
|
||||
# questions = json.load(f)
|
||||
|
||||
# report = {}
|
||||
|
||||
# # -----------------------
|
||||
# # Start Examination
|
||||
# # -----------------------
|
||||
|
||||
# doctor_speak(
|
||||
# "Welcome to the AI Insurance Medical Examination."
|
||||
# )
|
||||
|
||||
# doctor_speak(
|
||||
# "Do you have diabetes? Please answer yes or no."
|
||||
# )
|
||||
|
||||
# answer = patient_listen().lower()
|
||||
|
||||
# report["Diabetes"] = answer
|
||||
|
||||
# if "yes" in answer:
|
||||
|
||||
# for question in questions["diabetes"]:
|
||||
|
||||
# doctor_speak(question)
|
||||
|
||||
# response = patient_listen()
|
||||
|
||||
# report[question] = response
|
||||
|
||||
# # -----------------------
|
||||
# # Final Summary
|
||||
# # -----------------------
|
||||
|
||||
# doctor_speak(
|
||||
# "Thank you. The examination is complete."
|
||||
# )
|
||||
|
||||
# print("\n" + "=" * 60)
|
||||
# print("FINAL MEDICAL REPORT")
|
||||
# print("=" * 60)
|
||||
|
||||
# for key, value in report.items():
|
||||
# print(f"{key}: {value}")
|
||||
|
||||
# print("=" * 60)
|
||||
|
||||
# with open("medical_report.txt", "w") as f:
|
||||
|
||||
# f.write("FINAL MEDICAL REPORT\n")
|
||||
# f.write("=" * 60 + "\n\n")
|
||||
|
||||
# for key, value in report.items():
|
||||
# f.write(f"{key}: {value}\n")
|
||||
|
||||
# print("\nReport saved as medical_report.txt")
|
||||
|
||||
import json
|
||||
import speech_recognition as sr
|
||||
from elevenlabs.client import ElevenLabs
|
||||
from elevenlabs.play import play
|
||||
|
||||
# ElevenLabs
|
||||
client = ElevenLabs(
|
||||
api_key="sk_a5001c59bb470cefd481dc0fbdc1f3b1e1b5e2dd057929ea"
|
||||
)
|
||||
|
||||
# Load Questions
|
||||
with open("questions.json", "r") as f:
|
||||
questions = json.load(f)
|
||||
|
||||
report = {}
|
||||
|
||||
def doctor_speak(text):
|
||||
print(f"\n👨⚕️ Doctor: {text}")
|
||||
|
||||
audio = client.text_to_speech.convert(
|
||||
text=text,
|
||||
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
||||
model_id="eleven_multilingual_v2",
|
||||
output_format="mp3_44100_128",
|
||||
)
|
||||
|
||||
play(audio)
|
||||
|
||||
|
||||
def listen():
|
||||
r = sr.Recognizer()
|
||||
|
||||
with sr.Microphone() as source:
|
||||
|
||||
print("\n🎤 Speak now...")
|
||||
|
||||
audio = r.listen(source)
|
||||
|
||||
try:
|
||||
text = r.recognize_google(audio)
|
||||
|
||||
print("🧑 Patient:", text)
|
||||
|
||||
return text
|
||||
|
||||
except:
|
||||
return ""
|
||||
|
||||
|
||||
# Start Interview
|
||||
|
||||
doctor_speak(
|
||||
"Welcome to the AI Insurance Medical Examination."
|
||||
)
|
||||
|
||||
doctor_speak(
|
||||
"Do you have diabetes? Please answer yes or no."
|
||||
)
|
||||
|
||||
answer = listen().lower()
|
||||
|
||||
report["Diabetes"] = answer
|
||||
|
||||
if "yes" in answer:
|
||||
|
||||
for q in questions["diabetes"]:
|
||||
|
||||
doctor_speak(q)
|
||||
|
||||
response = listen()
|
||||
|
||||
report[q] = response
|
||||
|
||||
|
||||
doctor_speak(
|
||||
"Do you have hypertension? Please answer yes or no."
|
||||
)
|
||||
|
||||
answer = listen().lower()
|
||||
|
||||
report["Hypertension"] = answer
|
||||
|
||||
if "yes" in answer:
|
||||
|
||||
for q in questions["hypertension"]:
|
||||
|
||||
doctor_speak(q)
|
||||
|
||||
response = listen()
|
||||
|
||||
report[q] = response
|
||||
|
||||
|
||||
doctor_speak(
|
||||
"Do you smoke? Please answer yes or no."
|
||||
)
|
||||
|
||||
answer = listen().lower()
|
||||
|
||||
report["Smoking"] = answer
|
||||
|
||||
if "yes" in answer:
|
||||
|
||||
for q in questions["smoking"]:
|
||||
|
||||
doctor_speak(q)
|
||||
|
||||
response = listen()
|
||||
|
||||
report[q] = response
|
||||
|
||||
|
||||
doctor_speak(
|
||||
"Thank you. Examination completed."
|
||||
)
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("FINAL MEDICAL REPORT")
|
||||
print("=" * 60)
|
||||
|
||||
for k, v in report.items():
|
||||
print(f"{k}: {v}")
|
||||
|
||||
with open("medical_report.txt", "w") as f:
|
||||
|
||||
f.write("FINAL MEDICAL REPORT\n\n")
|
||||
|
||||
for k, v in report.items():
|
||||
f.write(f"{k}: {v}\n")
|
||||
|
||||
print("\nReport Saved -> medical_report.txt")
|
||||
@@ -0,0 +1,53 @@
|
||||
import json
|
||||
from elevenlabs.client import ElevenLabs
|
||||
from elevenlabs.play import play
|
||||
|
||||
# Add your API key
|
||||
client = ElevenLabs(
|
||||
api_key="sk_a5001c59bb470cefd481dc0fbdc1f3b1e1b5e2dd057929ea"
|
||||
)
|
||||
|
||||
def doctor_speak(text):
|
||||
print(f"\nDoctor: {text}")
|
||||
|
||||
audio = client.text_to_speech.convert(
|
||||
text=text,
|
||||
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
||||
model_id="eleven_multilingual_v2",
|
||||
output_format="mp3_44100_128",
|
||||
)
|
||||
|
||||
play(audio)
|
||||
|
||||
# Load questions
|
||||
with open("questions.json", "r") as f:
|
||||
questions = json.load(f)
|
||||
|
||||
answers = {}
|
||||
|
||||
doctor_speak("Welcome to the insurance medical examination.")
|
||||
|
||||
doctor_speak("Do you have diabetes? Please answer yes or no.")
|
||||
|
||||
response = input("Patient: ").strip().lower()
|
||||
|
||||
answers["Diabetes"] = response
|
||||
|
||||
if response == "yes":
|
||||
|
||||
for question in questions["diabetes"]:
|
||||
|
||||
doctor_speak(question)
|
||||
|
||||
answer = input("Patient: ")
|
||||
|
||||
answers[question] = answer
|
||||
|
||||
doctor_speak("Thank you. The examination is complete.")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("FINAL MEDICAL REPORT")
|
||||
print("=" * 60)
|
||||
|
||||
for key, value in answers.items():
|
||||
print(f"{key}: {value}")
|
||||
Reference in New Issue
Block a user