File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ export default defineCommand({
9898 process . stderr . write ( '[Model: music-2.5]\n' ) ;
9999 }
100100
101- if ( outPath && response . data . audio ) {
102- const audioBuffer = Buffer . from ( response . data . audio , 'hex' ) ;
101+ if ( outPath ) {
102+ const audioBuffer = Buffer . from ( response . data . audio ! , 'hex' ) ;
103103 writeFileSync ( outPath , audioBuffer ) ;
104104
105105 if ( config . quiet ) {
@@ -112,12 +112,13 @@ export default defineCommand({
112112 sample_rate : response . extra_info ?. audio_sample_rate ,
113113 } , format ) ) ;
114114 }
115- } else if ( response . data . audio_url ) {
115+ } else {
116+ const audioUrl = response . data . audio_url ?? response . data . audio ;
116117 if ( config . quiet ) {
117- console . log ( response . data . audio_url ) ;
118+ console . log ( audioUrl ) ;
118119 } else {
119120 console . log ( formatOutput ( {
120- url : response . data . audio_url ,
121+ url : audioUrl ,
121122 duration_ms : response . extra_info ?. audio_length ,
122123 size_bytes : response . extra_info ?. audio_size ,
123124 } , format ) ) ;
Original file line number Diff line number Diff line change @@ -121,9 +121,9 @@ export default defineCommand({
121121 process . stderr . write ( `[Model: ${ model } ]\n` ) ;
122122 }
123123
124- if ( outPath && response . data . audio ) {
125- // --out given: decode hex and save to file
126- const audioBuffer = Buffer . from ( response . data . audio , 'hex' ) ;
124+ if ( outPath ) {
125+ // output_format='hex': data.audio is hex-encoded binary
126+ const audioBuffer = Buffer . from ( response . data . audio ! , 'hex' ) ;
127127 writeFileSync ( outPath , audioBuffer ) ;
128128
129129 if ( config . quiet ) {
@@ -136,13 +136,14 @@ export default defineCommand({
136136 sample_rate : response . extra_info ?. audio_sample_rate ,
137137 } , format ) ) ;
138138 }
139- } else if ( response . data . audio_url ) {
140- // No --out: return URL
139+ } else {
140+ // output_format='url': API returns URL in data.audio (not data.audio_url)
141+ const audioUrl = response . data . audio_url ?? response . data . audio ;
141142 if ( config . quiet ) {
142- console . log ( response . data . audio_url ) ;
143+ console . log ( audioUrl ) ;
143144 } else {
144145 console . log ( formatOutput ( {
145- url : response . data . audio_url ,
146+ url : audioUrl ,
146147 duration_ms : response . extra_info ?. audio_length ,
147148 size_bytes : response . extra_info ?. audio_size ,
148149 } , format ) ) ;
You can’t perform that action at this time.
0 commit comments