Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

871 lines
25 KiB

  1. /*******************************************************************************
  2. * AlloOps.cpp *
  3. *-------------*
  4. * Description:
  5. * This module is the implementation file for the CAlloOps class.
  6. *-------------------------------------------------------------------------------
  7. * Created By: mc Date: 03/12/99
  8. * Copyright (C) 1999 Microsoft Corporation
  9. * All Rights Reserved
  10. *
  11. *******************************************************************************/
  12. //--- Additional includes
  13. #include "stdafx.h"
  14. #include "ms_entropicengine.h"
  15. #include <spdebug.h>
  16. #include "FeedChain.h"
  17. #include "Frontend.h"
  18. #include "AlloOps.h"
  19. //-----------------------------
  20. // Data.cpp
  21. //-----------------------------
  22. extern const unsigned short g_Opcode_To_ASCII[];
  23. extern const unsigned long g_AlloFlags[];
  24. /*****************************************************************************
  25. * CBookmarkList::~CBookmarkList *
  26. *-------------------------------*
  27. * Description:
  28. * Destructor for CBookmarkList
  29. *
  30. ********************************************************************** MC ***/
  31. CBookmarkList::~CBookmarkList()
  32. {
  33. SPDBG_FUNC( "CBookmarkList::~CBookmarkList" );
  34. BOOKMARK_ITEM* pItem;
  35. //----------------------------------------
  36. // Remove every item in link list.
  37. //----------------------------------------
  38. while( !m_BMList.IsEmpty() )
  39. {
  40. pItem = (BOOKMARK_ITEM*)m_BMList.RemoveHead();
  41. delete pItem;
  42. }
  43. } /* CBookmarkList::~CBookmarkList */
  44. /*****************************************************************************
  45. * CFEToken::CFEToken *
  46. *------------------------*
  47. * Description:
  48. * Initializer for CFEToken
  49. *
  50. ********************************************************************** MC ***/
  51. CFEToken::CFEToken()
  52. {
  53. SPDBG_FUNC( "CFEToken::CFEToken" );
  54. user_Volume = DEFAULT_USER_VOL;
  55. user_Rate = DEFAULT_USER_RATE;
  56. user_Pitch = DEFAULT_USER_PITCH;
  57. user_Emph = DEFAULT_USER_EMPH;
  58. user_Break = 0;
  59. pBMObj = NULL;
  60. memset( &tokStr[0], 0, sizeof(WCHAR) * TOKEN_LEN_MAX);
  61. tokLen = 0;
  62. memset( &phon_Str[0], 0, sizeof(short) * SP_MAX_PRON_LENGTH);
  63. phon_Len = 0;
  64. m_posClass = POS_UNK;
  65. POScode = MS_Unknown;
  66. m_TuneBoundaryType = NULL_BOUNDARY;
  67. m_Accent = K_NOACC;
  68. m_Boundary = K_NOBND;
  69. m_TermSil = 0;
  70. m_DurScale = 0.0f;
  71. m_ProsodyDurScale = 1.0f;
  72. m_PitchBaseOffs = 0.0f;
  73. m_PitchRangeScale = 1.0f;
  74. // The following don't need to be init'd
  75. m_PronType = PRON_LTS;
  76. sentencePosition = 0; // Source sentence position for this token
  77. sentenceLen = 0; // Source sentence length for this token
  78. srcPosition = 0; // Source position for this token
  79. srcLen = 0; // Source length for this token
  80. m_Accent_Prom = 0; // prominence prosodic control
  81. m_Boundary_Prom = 0; // prominence prosodic control
  82. m_TermSil = 0; // Pad word with silence (in sec)
  83. //--- Diagnostic
  84. m_AccentSource = ACC_NoSource;
  85. m_BoundarySource = BND_NoSource;
  86. m_SilenceSource = SIL_NoSource;
  87. } /* CFEToken::CFEToken */
  88. /*****************************************************************************
  89. * CFEToken::~CFEToken *
  90. *-----------------------*
  91. * Description:
  92. * Destructor for CFEToken
  93. *
  94. ********************************************************************** MC ***/
  95. CFEToken::~CFEToken()
  96. {
  97. SPDBG_FUNC( "CFEToken::~CFEToken" );
  98. if( pBMObj != NULL )
  99. {
  100. //---------------------------------------
  101. // Dispose bookmark list
  102. //---------------------------------------
  103. delete pBMObj;
  104. }
  105. } /* CFEToken::~CFEToken */
  106. /*****************************************************************************
  107. * CAlloCell::CAlloCell *
  108. *------------------------*
  109. * Description:
  110. * Initializer for CAlloCell
  111. *
  112. ********************************************************************** MC ***/
  113. CAlloCell::CAlloCell()
  114. {
  115. SPDBG_FUNC( "CAlloCell::CAlloCell" );
  116. long i;
  117. m_allo = _SIL_;
  118. m_dur = 0;
  119. m_ftDuration = m_UnitDur = 0;
  120. m_knots = KNOTS_PER_PHON;
  121. m_ctrlFlags = 0;
  122. m_user_Rate = 0;
  123. m_user_Volume = DEFAULT_USER_VOL;
  124. m_user_Pitch = 0;
  125. m_user_Emph = 0;
  126. m_user_Break = 0;
  127. m_Sil_Break = 0;
  128. m_Pitch_HI = 0;
  129. m_Pitch_LO = 0;
  130. m_pBMObj = NULL;
  131. m_ToBI_Boundary = K_NOBND;
  132. m_ToBI_Accent = K_NOACC;
  133. m_TuneBoundaryType = m_NextTuneBoundaryType = NULL_BOUNDARY;
  134. m_DurScale = 1.0;
  135. m_ProsodyDurScale = 1.0;
  136. m_PitchBaseOffs = 0.0f;
  137. m_PitchRangeScale = 1.0f;
  138. for( i = 0; i < KNOTS_PER_PHON; i++ )
  139. {
  140. m_ftTime[i] = 0;
  141. m_ftPitch[i] = 100;
  142. }
  143. m_Accent_Prom = 0; // prominence prosodic control
  144. m_Boundary_Prom = 0; // prominence prosodic control
  145. m_PitchBufStart = 0;
  146. m_PitchBufEnd = 0;
  147. m_SrcPosition = 0;
  148. m_SrcLen = 0;
  149. m_SentencePosition = 0;
  150. m_SentenceLen = 0;
  151. //--- Diagnostic
  152. m_AccentSource = ACC_NoSource;
  153. m_BoundarySource = BND_NoSource;
  154. m_SilenceSource = SIL_NoSource;
  155. m_pTextStr = NULL;
  156. } /* CAlloCell::CAlloCell */
  157. /*****************************************************************************
  158. * CAlloCell::~CAlloCell *
  159. *-----------------------*
  160. * Description:
  161. * Destructor for CAlloCell
  162. *
  163. ********************************************************************** MC ***/
  164. CAlloCell::~CAlloCell()
  165. {
  166. SPDBG_FUNC( "CAlloCell::~CAlloCell" );
  167. if( m_pBMObj != NULL )
  168. {
  169. //---------------------------------------
  170. // Dispose bookmark list
  171. //---------------------------------------
  172. delete m_pBMObj;
  173. }
  174. if( m_pTextStr != NULL )
  175. {
  176. //---------------------------------------
  177. // Dispose bookmark list
  178. //---------------------------------------
  179. delete m_pTextStr;
  180. }
  181. } /* CAlloCell::~CAlloCell */
  182. CAlloCell* CAlloCell::operator =( CAlloCell *pNewCell )
  183. {
  184. if ( pNewCell )
  185. {
  186. m_allo = pNewCell->m_allo;
  187. m_dur = pNewCell->m_dur;
  188. m_ftDuration = pNewCell->m_ftDuration;
  189. m_UnitDur = pNewCell->m_UnitDur;
  190. m_knots = pNewCell->m_knots;
  191. m_ctrlFlags = pNewCell->m_ctrlFlags;
  192. m_ToBI_Accent = pNewCell->m_ToBI_Accent;
  193. m_Accent_Prom = pNewCell->m_Accent_Prom;
  194. m_ToBI_Boundary = pNewCell->m_ToBI_Boundary;
  195. m_Boundary_Prom = pNewCell->m_Boundary_Prom;
  196. m_PitchBufStart = pNewCell->m_PitchBufStart;
  197. m_PitchBufEnd = pNewCell->m_PitchBufEnd;
  198. m_user_Volume = pNewCell->m_user_Volume;
  199. m_user_Rate = pNewCell->m_user_Rate;
  200. m_user_Pitch = pNewCell->m_user_Pitch;
  201. m_user_Emph = pNewCell->m_user_Emph;
  202. m_user_Break = pNewCell->m_user_Break;
  203. m_Sil_Break = pNewCell->m_Sil_Break;
  204. m_Pitch_HI = pNewCell->m_Pitch_HI;
  205. m_Pitch_LO = pNewCell->m_Pitch_LO;
  206. m_SrcPosition = pNewCell->m_SrcPosition;
  207. m_SrcLen = pNewCell->m_SrcLen;
  208. m_SentencePosition = pNewCell->m_SentencePosition;
  209. m_SentenceLen = pNewCell->m_SentenceLen;
  210. m_TuneBoundaryType = pNewCell->m_TuneBoundaryType;
  211. m_NextTuneBoundaryType = pNewCell->m_NextTuneBoundaryType;
  212. m_DurScale = pNewCell->m_DurScale;
  213. m_ProsodyDurScale = pNewCell->m_ProsodyDurScale;
  214. m_PitchBaseOffs = pNewCell->m_PitchBaseOffs;
  215. m_PitchRangeScale = pNewCell->m_PitchRangeScale;
  216. m_AccentSource = pNewCell->m_AccentSource;
  217. m_BoundarySource = pNewCell->m_BoundarySource;
  218. m_SilenceSource = pNewCell->m_SilenceSource;
  219. if ( pNewCell->m_pBMObj )
  220. {
  221. m_pBMObj->m_BMList = pNewCell->m_pBMObj->m_BMList;
  222. }
  223. if ( pNewCell->m_pTextStr )
  224. {
  225. m_pTextStr = new char[ strlen( pNewCell->m_pTextStr ) + 1 ];
  226. strcpy( m_pTextStr, pNewCell->m_pTextStr );
  227. }
  228. else
  229. {
  230. m_pTextStr = NULL;
  231. }
  232. memcpy( &pNewCell->m_ftTime, &m_ftTime, KNOTS_PER_PHON * sizeof( float ) );
  233. memcpy( &pNewCell->m_ftPitch, &m_ftPitch, KNOTS_PER_PHON * sizeof( float ) );
  234. }
  235. else
  236. {
  237. memset( this, 0, sizeof( this ) );
  238. }
  239. return this;
  240. }
  241. /*****************************************************************************
  242. * CAlloList::CAlloList *
  243. *------------------------*
  244. * Description:
  245. * Initialize list with 2 silence entries. These will
  246. * become the head an tail when real entries are stuffed
  247. *
  248. ********************************************************************** MC ***/
  249. CAlloList::CAlloList()
  250. {
  251. SPDBG_FUNC( "CAlloList::CAlloList" );
  252. CAlloCell *pCell;
  253. m_cAllos = 0;
  254. m_ListPos = NULL;
  255. //------------------------------------
  256. // Create initial TAIL silence cell
  257. //------------------------------------
  258. pCell = new CAlloCell;
  259. if( pCell )
  260. {
  261. m_AlloCellList.AddHead( pCell );
  262. pCell->m_ctrlFlags |= WORD_START + TERM_BOUND;
  263. pCell->m_TuneBoundaryType = TAIL_BOUNDARY;
  264. pCell->m_SilenceSource = SIL_Tail;
  265. m_cAllos++;
  266. }
  267. //------------------------------------
  268. // Create initial HEAD silence cell
  269. //------------------------------------
  270. pCell = new CAlloCell;
  271. if( pCell )
  272. {
  273. m_AlloCellList.AddHead( pCell );
  274. pCell->m_ctrlFlags |= WORD_START;
  275. pCell->m_SilenceSource = SIL_Head;
  276. m_cAllos++;
  277. }
  278. } /* CAlloList::CAlloList */
  279. /*****************************************************************************
  280. * CAlloList::~CAlloList *
  281. *-------------------------*
  282. * Description:
  283. * Remove every item in link list.
  284. *
  285. ********************************************************************** MC ***/
  286. CAlloList::~CAlloList()
  287. {
  288. SPDBG_FUNC( "CAlloList::~CAlloList" );
  289. CAlloCell *pCell;
  290. while( !m_AlloCellList.IsEmpty() )
  291. {
  292. pCell = (CAlloCell*)m_AlloCellList.RemoveHead();
  293. delete pCell;
  294. }
  295. } /* CAlloList::~CAlloList */
  296. /*****************************************************************************
  297. * CAlloList::GetAllo *
  298. *---------------------*
  299. * Description:
  300. * Return pointer of allocell at index
  301. *
  302. ********************************************************************** MC ***/
  303. CAlloCell *CAlloList::GetCell( long index )
  304. {
  305. SPDBG_FUNC( "CAlloList::GetCell" );
  306. return (CAlloCell*)m_AlloCellList.GetAt( m_AlloCellList.FindIndex( index ));
  307. } /* CAlloList::GetCell */
  308. /*****************************************************************************
  309. * CAlloList::GetTailCell *
  310. *-------------------------*
  311. * Description:
  312. * Return pointer of last allo in link list
  313. *
  314. ********************************************************************** MC ***/
  315. CAlloCell *CAlloList::GetTailCell()
  316. {
  317. SPDBG_FUNC( "CAlloList::GetTailCell" );
  318. return (CAlloCell*)m_AlloCellList.GetTail();
  319. } /* CAlloList::GetTailCell */
  320. /*****************************************************************************
  321. * CAlloList::GetTailCell *
  322. *-----------------------*
  323. * Description:
  324. * Return allo list size
  325. *
  326. ********************************************************************** MC ***/
  327. long CAlloList::GetCount()
  328. {
  329. SPDBG_FUNC( "CAlloList::GetCount" );
  330. return m_AlloCellList.GetCount();
  331. } /* CAlloList::GetCount */
  332. /*****************************************************************************
  333. * PrintPhon *
  334. *-----------*
  335. * Description:
  336. * Print 2-char allo name
  337. *
  338. ********************************************************************** MC ***/
  339. void PrintPhon( ALLO_CODE allo, char * /*msgStr*/)
  340. {
  341. SPDBG_FUNC( "PrintPhon" );
  342. unsigned short nChar;
  343. nChar = g_Opcode_To_ASCII[allo];
  344. if( nChar >> 8 )
  345. {
  346. SPDBG_DMSG1( "%c", nChar >> 8 );
  347. }
  348. if( nChar && 0xFF )
  349. {
  350. SPDBG_DMSG1( "%c", nChar & 0xFF );
  351. }
  352. } /* PrintPhon */
  353. /*****************************************************************************
  354. * CAlloList::OutAllos *
  355. *--------------------*
  356. * Description:
  357. * Dump ALLO_CELL contents
  358. *
  359. ********************************************************************** MC ***/
  360. void CAlloList::OutAllos()
  361. {
  362. SPDBG_FUNC( "CAlloOps::OutAllos" );
  363. CAlloCell *pCurCell;
  364. long i, flags, flagsT;
  365. char msgStr[400];
  366. for( i = 0; i < m_cAllos; i++ )
  367. {
  368. pCurCell = GetCell( i );
  369. flags = pCurCell->m_ctrlFlags;
  370. if( flags & WORD_START)
  371. {
  372. SPDBG_DMSG0( "\n" );
  373. }
  374. //----------------------------
  375. // Allo
  376. //----------------------------
  377. PrintPhon( pCurCell->m_allo, msgStr );
  378. //----------------------------
  379. // Duration
  380. //----------------------------
  381. SPDBG_DMSG1( "\t%.3f\t", pCurCell->m_ftDuration );
  382. //----------------------------
  383. // Boundry
  384. //----------------------------
  385. if( flags & BOUNDARY_TYPE_FIELD)
  386. {
  387. SPDBG_DMSG0( "(" );
  388. if( flags & WORD_START)
  389. {
  390. SPDBG_DMSG0( "-wS" );
  391. }
  392. if( flags & TERM_BOUND)
  393. {
  394. SPDBG_DMSG0( "-tB" );
  395. }
  396. SPDBG_DMSG0( ")\t" );
  397. }
  398. //----------------------------
  399. // Syllable type
  400. //----------------------------
  401. if( flags & SYLLABLE_TYPE_FIELD)
  402. {
  403. SPDBG_DMSG0( "(" );
  404. if( flags & WORD_END_SYLL)
  405. {
  406. SPDBG_DMSG0( "-wE" );
  407. }
  408. if( flags & TERM_END_SYLL)
  409. {
  410. SPDBG_DMSG0( "-tE" );
  411. }
  412. SPDBG_DMSG0( ")\t" );
  413. }
  414. //----------------------------
  415. // Syllable order
  416. //----------------------------
  417. if( flags & SYLLABLE_ORDER_FIELD)
  418. {
  419. SPDBG_DMSG0( "(" );
  420. flagsT = flags & SYLLABLE_ORDER_FIELD;
  421. if( flagsT == FIRST_SYLLABLE_IN_WORD)
  422. {
  423. SPDBG_DMSG0( "-Fs" );
  424. }
  425. else if( flagsT == MID_SYLLABLE_IN_WORD)
  426. {
  427. SPDBG_DMSG0( "-Ms" );
  428. }
  429. else if( flagsT == LAST_SYLLABLE_IN_WORD)
  430. {
  431. SPDBG_DMSG0( "-Ls" );
  432. }
  433. SPDBG_DMSG0( ")\t" );
  434. }
  435. //----------------------------
  436. // Stress
  437. //----------------------------
  438. if( flags & PRIMARY_STRESS)
  439. {
  440. SPDBG_DMSG0( "-Stress\t" );
  441. }
  442. //----------------------------
  443. // Word initial consonant
  444. //----------------------------
  445. if( flags & WORD_INITIAL_CONSONANT)
  446. {
  447. SPDBG_DMSG0( "-InitialK\t" );
  448. }
  449. //----------------------------
  450. // Syllable start
  451. //----------------------------
  452. if( flags & SYLLABLE_START)
  453. {
  454. SPDBG_DMSG0( "-Syll\t" );
  455. }
  456. SPDBG_DMSG0( "\n" );
  457. }
  458. } /* CAlloList::OutAllos */
  459. /*****************************************************************************
  460. * CAlloList::WordToAllo *
  461. *-----------------------*
  462. * Description:
  463. * Copy word token to AlloCells
  464. * Insert allos BEFORE 'pEndCell'
  465. *
  466. ********************************************************************** MC ***/
  467. bool CAlloList::WordToAllo( CFEToken *pPrevTok, CFEToken *pTok, CFEToken *pNextTok, CAlloCell *pEndCell )
  468. {
  469. SPDBG_FUNC( "CAlloList::WordToAllo" );
  470. long i;
  471. long startLatch;
  472. CAlloCell *pCurCell;
  473. long firstVowel, lastVoiced;
  474. bool gotAccent, isStressed;
  475. bool hasSpeech;
  476. //-----------------------------------------
  477. // First, find ToBI accent locations
  478. //-----------------------------------------
  479. firstVowel = lastVoiced = (-1);
  480. gotAccent = false;
  481. hasSpeech = false;
  482. for( i = 0; i < pTok->phon_Len; i++ )
  483. {
  484. isStressed = false;
  485. if( pTok->phon_Str[i] < _STRESS1_ )
  486. {
  487. //----------------------------
  488. // Potential ToBI accent
  489. //----------------------------
  490. if( (!gotAccent) && (g_AlloFlags[pTok->phon_Str[i]] & KVOWELF) )
  491. {
  492. if( (i < (pTok->phon_Len -1)) && (pTok->phon_Str[i+1] == _STRESS1_) )
  493. {
  494. //-------------------------------------
  495. // Put accent at 1st stressed vowel
  496. //-------------------------------------
  497. firstVowel = i;
  498. gotAccent = true;
  499. }
  500. else if( firstVowel < 0 )
  501. {
  502. //-------------------------------------
  503. // In case there's no stressed vowel
  504. // in this word, use 1st vowel
  505. //-------------------------------------
  506. firstVowel = i;
  507. }
  508. }
  509. //----------------------------
  510. // Potential ToBI boundary
  511. //----------------------------
  512. if( g_AlloFlags[pTok->phon_Str[i]] & KVOICEDF )
  513. {
  514. lastVoiced = i;
  515. }
  516. }
  517. }
  518. //-----------------------------------------
  519. // Now, copy data to allo list
  520. //-----------------------------------------
  521. startLatch = true;
  522. for( i = 0; i < pTok->phon_Len; i++ )
  523. {
  524. if( pTok->phon_Str[i] < _STRESS1_ )
  525. {
  526. if( (pTok->phon_Str[i] == _SIL_) && (pTok->m_TuneBoundaryType >= SUB_BOUNDARY_1) )
  527. {
  528. //----------------------------------------------------------------
  529. // Before skipping this, propagate the dur scale gain
  530. //----------------------------------------------------------------
  531. if( pTok->m_DurScale == 0 )
  532. {
  533. if( pPrevTok )
  534. {
  535. pTok->m_DurScale = pPrevTok->m_DurScale;
  536. }
  537. else
  538. {
  539. pTok->m_DurScale = 1.0;
  540. }
  541. }
  542. continue;
  543. }
  544. //------------------------------------
  545. // Create new cell
  546. //------------------------------------
  547. pCurCell = new CAlloCell;
  548. if( pCurCell )
  549. {
  550. m_AlloCellList.InsertBefore( m_AlloCellList.Find(pEndCell), pCurCell);
  551. m_cAllos++;
  552. //----------------------------
  553. // Copy only phons
  554. //----------------------------
  555. pCurCell->m_allo = (ALLO_CODE) pTok->phon_Str[i];
  556. //---------------------------------------------
  557. // See if this allo will generate speech
  558. //---------------------------------------------
  559. if( (pCurCell->m_allo >= _IY_) &&
  560. (pCurCell->m_allo <= _DX_) &&
  561. (pCurCell->m_allo != _SIL_) )
  562. {
  563. hasSpeech = true;
  564. }
  565. //----------------------------
  566. // Save src position
  567. //----------------------------
  568. pCurCell->m_SrcPosition = pTok->srcPosition;
  569. pCurCell->m_SrcLen = pTok->srcLen;
  570. pCurCell->m_SentencePosition = pTok->sentencePosition;
  571. pCurCell->m_SentenceLen = pTok->sentenceLen;
  572. //----------------------------
  573. // Flag WORD START?
  574. //----------------------------
  575. if( startLatch )
  576. {
  577. pCurCell->m_ctrlFlags |= WORD_START;
  578. startLatch = false;
  579. }
  580. //----------------------------
  581. // Is next allo a STRESS?
  582. //----------------------------
  583. if( i < (pTok->phon_Len -1) )
  584. {
  585. if( pTok->phon_Str[i+1] == _STRESS1_ )
  586. {
  587. pCurCell->m_ctrlFlags |= PRIMARY_STRESS;
  588. }
  589. else
  590. {
  591. //----------------------------------------------
  592. // Voice inventory does not have unstressed
  593. // entries for these diphongs
  594. //----------------------------------------------
  595. if( (pCurCell->m_allo == _AW_) ||
  596. (pCurCell->m_allo == _AY_) ||
  597. (pCurCell->m_allo == _EY_) ||
  598. (pCurCell->m_allo == _OY_) )
  599. {
  600. pCurCell->m_ctrlFlags |= PRIMARY_STRESS;
  601. }
  602. }
  603. }
  604. //---------------------------
  605. // Diagnostic
  606. //---------------------------
  607. if( pCurCell->m_allo == _SIL_ )
  608. {
  609. pCurCell->m_SilenceSource = pTok->m_SilenceSource;
  610. }
  611. //----------------------------
  612. // Place ToBI accent
  613. //----------------------------
  614. if( i == firstVowel )
  615. {
  616. pCurCell->m_ToBI_Accent = pTok->m_Accent;
  617. //---------------------------
  618. // Diagnostic
  619. //---------------------------
  620. pCurCell->m_AccentSource = pTok->m_AccentSource;
  621. pCurCell->m_pTextStr = new char[pTok->tokLen+1];
  622. if( pCurCell->m_pTextStr )
  623. {
  624. WideCharToMultiByte ( CP_ACP, 0,
  625. pTok->tokStr, -1,
  626. pCurCell->m_pTextStr, pTok->tokLen+1,
  627. NULL, NULL);
  628. }
  629. }
  630. pCurCell->m_Accent_Prom = pTok->m_Accent_Prom;
  631. //----------------------------
  632. // Place ToBI boundary
  633. //----------------------------
  634. if( i == lastVoiced )
  635. {
  636. pCurCell->m_ToBI_Boundary = pTok->m_Boundary;
  637. //---------------------------
  638. // Diagnostic
  639. //---------------------------
  640. pCurCell->m_BoundarySource = pTok->m_BoundarySource;
  641. }
  642. pCurCell->m_Boundary_Prom = pTok->m_Boundary_Prom;
  643. //----------------------------
  644. // User Controls
  645. //----------------------------
  646. pCurCell->m_user_Volume = pTok->user_Volume;
  647. pCurCell->m_user_Rate = pTok->user_Rate;
  648. pCurCell->m_user_Pitch = pTok->user_Pitch;
  649. pCurCell->m_user_Emph = 0;
  650. if( pTok->user_Emph > 0 )
  651. {
  652. if( i == firstVowel )
  653. {
  654. pCurCell->m_user_Emph = pTok->user_Emph;
  655. pCurCell->m_ctrlFlags |= PRIMARY_STRESS;
  656. }
  657. }
  658. pCurCell->m_user_Break = pTok->user_Break;
  659. pCurCell->m_pBMObj = pTok->pBMObj;
  660. pTok->pBMObj = NULL;
  661. //-----------------------------------------------
  662. // If token's m_DurScale is not defined,
  663. // try to use prev token's ratio
  664. //-----------------------------------------------
  665. if( pTok->m_DurScale == 0 )
  666. {
  667. if( pPrevTok )
  668. {
  669. pCurCell->m_DurScale = pPrevTok->m_DurScale;
  670. }
  671. else
  672. {
  673. pCurCell->m_DurScale = 1.0;
  674. }
  675. //-------------------------------------------------------
  676. // Write back in case next token is also undefined
  677. //-------------------------------------------------------
  678. pTok->m_DurScale = pCurCell->m_DurScale;
  679. }
  680. else
  681. {
  682. pCurCell->m_DurScale = pTok->m_DurScale;
  683. }
  684. pCurCell->m_ProsodyDurScale = pTok->m_ProsodyDurScale;
  685. if( pNextTok )
  686. {
  687. pCurCell->m_NextTuneBoundaryType = pNextTok->m_TuneBoundaryType;
  688. }
  689. else
  690. {
  691. pCurCell->m_NextTuneBoundaryType = NULL_BOUNDARY;
  692. }
  693. pCurCell->m_PitchBaseOffs = pTok->m_PitchBaseOffs;
  694. pCurCell->m_PitchRangeScale = pTok->m_PitchRangeScale;
  695. //----------------------------------------------
  696. // Is this a term word?
  697. //----------------------------------------------
  698. pCurCell->m_TuneBoundaryType = pTok->m_TuneBoundaryType;
  699. if( pTok->m_TuneBoundaryType != NULL_BOUNDARY )
  700. {
  701. pCurCell->m_ctrlFlags |= TERM_BOUND + WORD_START;
  702. }
  703. }
  704. }
  705. }
  706. //----------------------------------------
  707. // Insert word pause?
  708. //----------------------------------------
  709. if( pTok->m_TermSil > 0 )
  710. {
  711. pCurCell = new CAlloCell;
  712. if( pCurCell )
  713. {
  714. m_AlloCellList.InsertBefore( m_AlloCellList.Find(pEndCell), pCurCell);
  715. m_cAllos++;
  716. //----------------------------
  717. // Add silence
  718. //----------------------------
  719. pCurCell->m_allo = _SIL_;
  720. //----------------------------
  721. // Save src position
  722. //----------------------------
  723. pCurCell->m_SrcPosition = pTok->srcPosition;
  724. pCurCell->m_SrcLen = pTok->srcLen;
  725. pCurCell->m_SentencePosition = pTok->sentencePosition;
  726. pCurCell->m_SentenceLen = pTok->sentenceLen;
  727. //----------------------------
  728. // User Controls
  729. //----------------------------
  730. pCurCell->m_user_Volume = pTok->user_Volume;
  731. pCurCell->m_user_Rate = pTok->user_Rate;
  732. pCurCell->m_user_Pitch = pTok->user_Pitch;
  733. pCurCell->m_user_Emph = pTok->user_Emph;
  734. pCurCell->m_user_Break = pTok->user_Break;
  735. pCurCell->m_pBMObj = NULL;
  736. pCurCell->m_TuneBoundaryType = pTok->m_TuneBoundaryType;
  737. pCurCell->m_Boundary_Prom = pTok->m_Boundary_Prom;
  738. pCurCell->m_Accent_Prom = pTok->m_Accent_Prom;
  739. pCurCell->m_ctrlFlags = 0;
  740. pCurCell->m_UnitDur = pTok->m_TermSil;
  741. pCurCell->m_Sil_Break = (unsigned long)(pCurCell->m_UnitDur * 1000); // sec -> ms
  742. pCurCell->m_user_Break = 0;
  743. pCurCell->m_DurScale = pTok->m_DurScale;
  744. pCurCell->m_ProsodyDurScale = 1.0f;
  745. }
  746. }
  747. return hasSpeech;
  748. } /* CAlloList::WordToAllo */