61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
import asyncio
|
|
import os
|
|
import sys
|
|
from dotenv import load_dotenv
|
|
|
|
if sys.stdout.encoding != 'utf-8':
|
|
try:
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
except Exception:
|
|
pass
|
|
|
|
load_dotenv()
|
|
|
|
async def test_sarvam_anushka():
|
|
api_key = os.getenv("SARVAM_API_KEY")
|
|
import httpx2
|
|
client = httpx2.AsyncClient(timeout=15.0)
|
|
headers = {
|
|
"api-subscription-key": api_key,
|
|
"Content-Type": "application/json",
|
|
}
|
|
payload = {
|
|
"inputs": ["வணக்கம், உங்கள் உடல்நலம் எப்படி உள்ளது?"],
|
|
"target_language_code": "ta-IN",
|
|
"speaker": "anushka",
|
|
"model": "bulbul:v2",
|
|
}
|
|
res = await client.post(
|
|
"https://api.sarvam.ai/text-to-speech",
|
|
json=payload,
|
|
headers=headers,
|
|
)
|
|
if res.status_code == 200:
|
|
audios = res.json().get("audios", [])
|
|
print(f"[OK] Sarvam TTS bulbul:v2 (anushka) SUCCESS! Audio segments: {len(audios)}")
|
|
return True
|
|
else:
|
|
print(f"[FAIL] Sarvam error {res.status_code}: {res.text}")
|
|
return False
|
|
|
|
async def list_anthropic_models():
|
|
api_key = os.getenv("ANTHROPIC_API_KEY")
|
|
from anthropic import AsyncAnthropic
|
|
client = AsyncAnthropic(api_key=api_key)
|
|
try:
|
|
models = await client.models.list()
|
|
print("Available Anthropic models on this account:")
|
|
for m in models.data:
|
|
print(f" - {m.id} ({m.display_name})")
|
|
except Exception as e:
|
|
print(f"Anthropic list models error: {e}")
|
|
|
|
async def main():
|
|
print("--- 1. Testing Sarvam ---")
|
|
await test_sarvam_anushka()
|
|
print("\n--- 2. Listing Anthropic Models ---")
|
|
await list_anthropic_models()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|