File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 33.pytest_cache /
44jigsawstack.egg-info /
55
6- / __pycache__ /
6+ __pycache__ /
77/.pytest_cache /
88/.vscode /
99/.idea /
Original file line number Diff line number Diff line change 1+ import os
2+ from jigsawstack import JigsawStack
3+ import logging
4+ import sys
5+
6+ # Enable detailed debug logging
7+ logging .basicConfig (level = logging .DEBUG ,
8+ format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' ,
9+ stream = sys .stdout )
10+
11+ # Initialize the client with your API key
12+ api_key = "sk_6b0e5f86bcf014f4354cf617404a20422392d2a0115cd2520057fea5c3fdf8ce9ff0b972791649962937cb3cb167d0437bc7fdf61b99627bc838729b8037589f024rIVykPhD2e5VthayPN"
13+ jigsaw = JigsawStack (api_key = api_key )
14+
15+ # Test text to speech
16+ try :
17+ print ("Making text-to-speech request..." )
18+ result = jigsaw .audio .text_to_speech ({
19+ "text" : "Hello, how are you doing?" ,
20+ })
21+
22+ # Check response type
23+ print (f"Response type: { type (result )} " )
24+ print (f"Response keys: { result .keys () if hasattr (result , 'keys' ) else 'No keys' } " )
25+
26+ # Save the audio file
27+ if result and isinstance (result , dict ) and 'audio_data' in result :
28+ with open ("output.mp3" , "wb" ) as f :
29+ f .write (result ["audio_data" ])
30+ print (f"Audio saved successfully with content type: { result .get ('content_type' )} " )
31+ print (f"Audio size: { len (result ['audio_data' ])} bytes" )
32+ else :
33+ print ("No audio data received in response" )
34+ print (f"Response contents: { result } " )
35+
36+ except Exception as e :
37+ print (f"Error: { str (e )} " )
38+ import traceback
39+ traceback .print_exc ()
You can’t perform that action at this time.
0 commit comments