53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
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}") |