@@ -202,6 +202,105 @@ describe('speech synthesize command', () => {
202202 console . log = originalLog ;
203203 }
204204 } ) ;
205+
206+ it ( '--pronunciation serializes multiple values with the API-compatible shape' , async ( ) => {
207+ const config = {
208+ apiKey : 'test-key' ,
209+ region : 'global' as const ,
210+ baseUrl : 'https://api.mmx.io' ,
211+ output : 'json' as const ,
212+ timeout : 10 ,
213+ verbose : false ,
214+ quiet : false ,
215+ noColor : true ,
216+ yes : false ,
217+ dryRun : true ,
218+ nonInteractive : true ,
219+ async : false ,
220+ } ;
221+
222+ const originalLog = console . log ;
223+ let output = '' ;
224+ console . log = ( msg : string ) => { output += msg ; } ;
225+
226+ try {
227+ await synthesizeCommand . execute ( config , {
228+ text : '处理这个危险的情况。' ,
229+ pronunciation : [
230+ '处理/(chu3)(li3)' ,
231+ '危险/dangerous' ,
232+ ] ,
233+ quiet : false ,
234+ verbose : false ,
235+ noColor : true ,
236+ yes : false ,
237+ dryRun : true ,
238+ help : false ,
239+ nonInteractive : true ,
240+ async : false ,
241+ } ) ;
242+
243+ const parsed = JSON . parse ( output ) ;
244+
245+ // pronunciation_dict is an object with a tone string array — not the
246+ // old array-of-{text,tone} shape — and each value is preserved verbatim
247+ // (no splitting, trimming, or rewriting), covering both the pinyin form
248+ // and the plain-replacement form shown in the official API docs.
249+ expect ( Array . isArray ( parsed . request . pronunciation_dict ) ) . toBe ( false ) ;
250+ expect ( parsed . request . pronunciation_dict ) . toEqual ( {
251+ tone : [
252+ '处理/(chu3)(li3)' ,
253+ '危险/dangerous' ,
254+ ] ,
255+ } ) ;
256+ } finally {
257+ console . log = originalLog ;
258+ }
259+ } ) ;
260+
261+ it ( '--pronunciation with a single value serializes under tone' , async ( ) => {
262+ const config = {
263+ apiKey : 'test-key' ,
264+ region : 'global' as const ,
265+ baseUrl : 'https://api.mmx.io' ,
266+ output : 'json' as const ,
267+ timeout : 10 ,
268+ verbose : false ,
269+ quiet : false ,
270+ noColor : true ,
271+ yes : false ,
272+ dryRun : true ,
273+ nonInteractive : true ,
274+ async : false ,
275+ } ;
276+
277+ const originalLog = console . log ;
278+ let output = '' ;
279+ console . log = ( msg : string ) => { output += msg ; } ;
280+
281+ try {
282+ await synthesizeCommand . execute ( config , {
283+ text : 'Omg, the real danger is not that computers start thinking.' ,
284+ pronunciation : [ 'Omg/Oh my god' ] ,
285+ quiet : false ,
286+ verbose : false ,
287+ noColor : true ,
288+ yes : false ,
289+ dryRun : true ,
290+ help : false ,
291+ nonInteractive : true ,
292+ async : false ,
293+ } ) ;
294+
295+ const parsed = JSON . parse ( output ) ;
296+
297+ expect ( parsed . request . pronunciation_dict ) . toEqual ( {
298+ tone : [ 'Omg/Oh my god' ] ,
299+ } ) ;
300+ } finally {
301+ console . log = originalLog ;
302+ }
303+ } ) ;
205304} ) ;
206305
207306describe ( 'speech synthesize format validation' , ( ) => {
0 commit comments