Quickstart
Get started with ProsodyAI in 5 minutes
Quickstart
Get ProsodyAI running in your application in under 5 minutes.
Prerequisites
- Node.js 18+ or Python 3.9+
- A ProsodyAI API key (get one here)
Install the SDK
npm install @prosody/sdkpnpm add @prosody/sdkyarn add @prosody/sdkpip install prosody-sdkInitialize the Client
import { Prosody } from '@prosody/sdk';
const client = new Prosody({
apiKey: process.env.PROSODY_API_KEY,
});from prosody import Prosody
client = Prosody(api_key=os.environ["PROSODY_API_KEY"])Analyze Audio
const result = await client.analyze({
audio: audioBuffer,
vertical: 'contact_center',
features: ['emotion', 'prosody', 'prediction'],
});
console.log(result.emotion); // "frustrated"
console.log(result.valence); // -0.6
console.log(result.escalationRisk); // "high"
console.log(result.predictedCsat); // 2.3result = client.analyze(
audio=audio_bytes,
vertical="contact_center",
features=["emotion", "prosody", "prediction"],
)
print(result.emotion) # "frustrated"
print(result.valence) # -0.6
print(result.escalation_risk) # "high"
print(result.predicted_csat) # 2.3Stream Real-Time Analysis
For real-time applications, use the streaming API:
const stream = client.stream({
vertical: 'contact_center',
sessionId: 'call-12345',
});
stream.on('emotion', (data) => {
console.log(`Emotion: ${data.emotion} (${data.confidence})`);
});
stream.on('prediction', (data) => {
console.log(`Escalation risk: ${data.escalationRisk}`);
console.log(`Predicted CSAT: ${data.predictedCsat}`);
});
// Send audio chunks as they arrive
mediaRecorder.ondataavailable = (e) => {
stream.send(e.data);
};
// End the session
stream.end();async with client.stream(
vertical="contact_center",
session_id="call-12345",
) as stream:
async for chunk in audio_source:
await stream.send(chunk)
result = await stream.receive()
if result:
print(f"Emotion: {result.emotion}")
print(f"Escalation risk: {result.escalation_risk}")Next Steps
Ready to dive deeper? Check out the full SDK documentation or API reference.
- Configure verticals for your industry
- Set up webhooks for async processing
- Integrate with LangChain for AI agents
- Fine-tune models on your data