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.

121 lines
3.2 KiB

  1. /******************************************************************************
  2. * UnitSearch.h *
  3. *--------------*
  4. *
  5. *------------------------------------------------------------------------------
  6. * Copyright (C) 2000 Microsoft Corporation Date: 03/02/00 - 12/5/00
  7. * All Rights Reserved
  8. *
  9. ********************************************************************* mplumpe ***/
  10. #ifndef __UNITSEARCH_H_
  11. #define __UNITSEARCH_H_
  12. #include <stdio.h>
  13. #include <vector>
  14. class CSpeakerData;
  15. struct DPLink;
  16. struct Phone;
  17. struct ChkDescript;
  18. struct WeightsBasic
  19. {
  20. float f0;
  21. float dur;
  22. float rms;
  23. float lkl;
  24. float cont;
  25. float sameSeg;
  26. };
  27. struct Weights
  28. {
  29. float f0;
  30. float dur;
  31. float rms;
  32. float lkl;
  33. float cont;
  34. float sameSeg;
  35. float phBdr;
  36. float f0Bdr;
  37. };
  38. struct SegInfo;
  39. struct DPCand
  40. {
  41. SegInfo* segment;
  42. double f0Weight;
  43. double durWeight;
  44. double lklWeight;
  45. double rmsWeight;
  46. double contWeight;
  47. double acumWeight;
  48. int prevPath;
  49. };
  50. struct DPLink
  51. {
  52. std::vector<DPCand> m_cands;
  53. int m_iBestPath;
  54. double m_dTime;
  55. double m_dAverRms;
  56. double m_dAverDur;
  57. double m_dAverF0;
  58. double m_dTargF0;
  59. };
  60. class CUnitSearch
  61. {
  62. public:
  63. CUnitSearch(int iDynSearch = 0, int iBlend = 0, int iUseTargetF0 = 0, int iUseGain = 0);
  64. void SetSpeakerData (CSpeakerData* pSpeakerData);
  65. int Search (Phone* pPhList, int iNumPh, ChkDescript** ppChunks, int* piNumChunks, double dStartTime);
  66. private:
  67. void ComputeDPInfo (DPLink* rLastLink, DPLink& rNewLink, double targetF0);
  68. int FindOptimalPath (std::vector<DPLink>& rDPList, double dStartTime, ChkDescript** ppChunks, int* piNumChunks);
  69. void Backtrack (std::vector<DPLink>& rDPList, int* piIndexes);
  70. int GenerateOutput (ChkDescript** chunks, int* nChunks, const char* cluster,
  71. double time, int chunkIdx, double from, double to, double rms,
  72. double targF0, double srcF0, double gain);
  73. int AddChunk (ChkDescript** ppChunks, int* piNumChunks, const char* pszName, double dTime,
  74. int iChunkIdx, double dFrom, double dTo, double targF0, double srcF0, double dGain);
  75. void FlushOutput (ChkDescript** ppChunks, int* piNumChunks);
  76. int CentralPhone ( const char *pszTriphone, char *pszPhone );
  77. int Unvoiced (const char* pszPhone);
  78. int m_iDynSearch;
  79. int m_iBlend;
  80. int m_iUseTargetF0;
  81. int m_iUseGain;
  82. Weights m_weights;
  83. CSpeakerData* m_pSpeakerData;
  84. // Blend variables
  85. char m_pszLastPhone[20];
  86. char m_pszUnitName[1024]; //Don't know if this is enough (We probably don't need it)
  87. int m_iChunkIdx1;
  88. double m_dTime1;
  89. double m_dFrom1;
  90. double m_dTo1;
  91. double m_dGain1;
  92. double m_dNumAcum;
  93. // f0 ratio
  94. double m_dSrcF0;
  95. double m_dTargF0;
  96. int m_iNumSrcF0;
  97. int m_iNumTargF0;
  98. // Worker variables used in Search, here so they aren't constantly deleted and re-allocated
  99. std::vector<DPLink> m_dpList;
  100. DPLink m_dpLink;
  101. };
  102. #endif