Skip to content

Commit

Permalink
Correct sampling rate in SAPI from model
Browse files Browse the repository at this point in the history
SAPI retrieves actual sampling rate from model
  • Loading branch information
m-toman committed Dec 1, 2014
1 parent e096b70 commit bc8a0a1
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.tlog
*.unsuccessfulbuild
*.sdf
*.exp
*.exp
salb.opensdf
4 changes: 2 additions & 2 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ SALB

Copyright (c)
-------------
2014 FTW GmbH
2014 FTW Telecommunications Research Center Vienna
2014 The University of Edinburgh
All rights reserved.

Contact
-------
TTS System: Markus Toman ([email protected])
General: Markus Toman ([email protected])
Austrian German Voice: Michael Pucher ([email protected])

The 3rd party libraries remain unchanged except
Expand Down
2 changes: 1 addition & 1 deletion engine/manager/src/HTSEngineSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ TTSResultPtr HTSEngineSynthesizer::SynthesizeLabels(const FragmentPropertiesPtr&
if (i >> pitch) {
//TODO: this is not exactly what we want
//HTS_Engine_set_alpha(&engine, pitch);
HTS_Engine_add_half_tone( &engine, pitch );
HTS_Engine_add_half_tone(&engine, pitch);
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine/manager/src/Synthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace htstts {

SynthesizerPtr Synthesizer::NewSynthesizer(const std::string& type) {
// once we have other synthesizers, add them here
// once we have other synthesizers, add them here
return SynthesizerPtr(new HTSEngineSynthesizer());
}

Expand Down
2 changes: 1 addition & 1 deletion salb.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sapi", "sapi\htssapi.vcxproj", "{39DEAE4C-AB16-477D-99BF-125454577F20}"
ProjectSection(ProjectDependencies) = postProject
{269C0C70-D137-48BE-9520-2460D8526FEA} = {269C0C70-D137-48BE-9520-2460D8526FEA}
{F8A68187-8DF4-4AB3-8146-3C7B8AE1E588} = {F8A68187-8DF4-4AB3-8146-3C7B8AE1E588}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sapiPS", "sapi\htssapiPS.vcxproj", "{B0662BE3-CD08-45ED-ABC8-14BC3ACF925A}"
Expand All @@ -26,6 +25,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cli", "cli\cli.vcxproj", "{
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sapi_register", "sapi\register\register.vcxproj", "{F8A68187-8DF4-4AB3-8146-3C7B8AE1E588}"
ProjectSection(ProjectDependencies) = postProject
{39DEAE4C-AB16-477D-99BF-125454577F20} = {39DEAE4C-AB16-477D-99BF-125454577F20}
{B0662BE3-CD08-45ED-ABC8-14BC3ACF925A} = {B0662BE3-CD08-45ED-ABC8-14BC3ACF925A}
EndProjectSection
EndProject
Expand Down
38 changes: 38 additions & 0 deletions sapi/dlldata.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*********************************************************
DllData file -- generated by MIDL compiler
DO NOT ALTER THIS FILE
This file is regenerated by MIDL on every IDL file compile.
To completely reconstruct this file, delete it and rerun MIDL
on all the IDL files in this DLL, specifying this file for the
/dlldata command line option
*********************************************************/

#define PROXY_DELEGATION

#include <rpcproxy.h>

#ifdef __cplusplus
extern "C" {
#endif

EXTERN_PROXY_FILE( htssapi )


PROXYFILE_LIST_START
/* Start of list */
REFERENCE_PROXY_FILE( htssapi ),
/* End of list */
PROXYFILE_LIST_END


DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )

#ifdef __cplusplus
} /*extern "C" */
#endif

/* end of generated dlldata file */
3 changes: 0 additions & 3 deletions sapi/htssapi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,6 @@
<ItemGroup>
<ResourceCompile Include="htssapi.rc" />
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<None Include="htssapi.def" />
<None Include="htssapi.rgs" />
Expand Down
3 changes: 0 additions & 3 deletions sapi/htssapi.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<None Include="htssapi.rgs">
<Filter>Resource Files</Filter>
Expand Down
32 changes: 16 additions & 16 deletions sapi/htstts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace htstts;

static double ConvertSapiRate(int r);

static TTSManager ttsManager;
static TTSManager ttsManager;

/******************************************************************************
* HTSTTS Constructor
Expand Down Expand Up @@ -111,29 +111,29 @@ STDMETHODIMP HTSTTS::GetOutputFormat(const GUID* pTargetFormatId,
GUID* pDesiredFormatId,
WAVEFORMATEX** ppCoMemDesiredWaveFormatEx) {

//return SpConvertStreamFormatEnum(SPSF_48kHz16BitMono,
// pDesiredFormatId,
// ppCoMemDesiredWaveFormatEx);
WAVEFORMATEX* wfx;

//TODO: return something reasonable that the synthesizer delivers
// or resample our synthesized data
// or tell the synthesizer what to deliver
return SpConvertStreamFormatEnum(SPSF_48kHz16BitMono,
pDesiredFormatId,
ppCoMemDesiredWaveFormatEx);
TTSResultPtr result = ttsManager.SynthesizeTextFragment(
TextFragmentPtr(new TextFragment("", this->voiceProperties)));

/*
if ((wfx = (WAVEFORMATEX *)CoTaskMemAlloc(sizeof(*wfx))) == NULL)
return E_OUTOFMEMORY;
if ((wfx = (WAVEFORMATEX*)CoTaskMemAlloc(sizeof(*wfx))) == NULL) {
return E_OUTOFMEMORY;
}
memset(wfx, 0, sizeof(*wfx));
wfx->nChannels = 1;
wfx->nSamplesPerSec = get_param_int(curr_vox->features, "sample_rate", 48000);
wfx->nSamplesPerSec = result->GetSamplingRate();
wfx->wFormatTag = WAVE_FORMAT_PCM;
wfx->wBitsPerSample = 16;
wfx->nBlockAlign = wfx->nChannels*wfx->wBitsPerSample/8;
wfx->nAvgBytesPerSec = wfx->nSamplesPerSec*wfx->nBlockAlign;
wfx->nBlockAlign = wfx->nChannels * wfx->wBitsPerSample / 8;
wfx->nAvgBytesPerSec = wfx->nSamplesPerSec * wfx->nBlockAlign;

*pDesiredFormatId = SPDFID_WaveFormatEx;
*ppCoMemDesiredWaveFormatEx = wfx;
*/
//return S_OK;

return S_OK;
}


Expand Down Expand Up @@ -246,7 +246,7 @@ HTSTTS::Speak(DWORD dwSpeakFlags,

LOG_DEBUG("[Speak] Writing buffer");

//- a lot of ugly code incoming again
//- ugly code incoming again
//- unfortunately we have to prebuffer the whole sample as the SAPI write
//- function does not work on all tested systems
//- when single samples (not bytes!) are written.
Expand Down

0 comments on commit bc8a0a1

Please sign in to comment.