Click here to Skip to main content
16,005,290 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Reading all lines of a file Pin
gecool5-Oct-05 21:13
gecool5-Oct-05 21:13 
GeneralRe: Reading all lines of a file Pin
Anonymous6-Oct-05 21:28
Anonymous6-Oct-05 21:28 
GeneralRe: Reading all lines of a file Pin
Anonymous9-Oct-05 20:08
Anonymous9-Oct-05 20:08 
QuestionClient/server .... please HELP Pin
Member 23297074-Oct-05 7:21
Member 23297074-Oct-05 7:21 
AnswerRe: Client/server .... please HELP Pin
Member 19471947-Oct-05 10:53
Member 19471947-Oct-05 10:53 
QuestionC++ Problems... Pin
AndrewVos3-Oct-05 16:33
AndrewVos3-Oct-05 16:33 
AnswerRe: C++ Problems... Pin
Judah Gabriel Himango4-Oct-05 11:35
sponsorJudah Gabriel Himango4-Oct-05 11:35 
GeneralRe: C++ Problems... Pin
AndrewVos5-Oct-05 18:24
AndrewVos5-Oct-05 18:24 
Cool, didnt get an email notifying me of a response.. sorry it took so long.

Heres the code. Its from a Microsoft sample app for creating a voice font, for SAPI.


/******************************************************************************
* mkvoice.cpp *
*-------------*
* This application assembles a simple voice font for the sample TTS engine.
*Copyright (c) Microsoft Corporation. All rights reserved.
*
******************************************************************************/
#include "stdafx.h"
#include <ttseng_i.c>
#include <direct.h>

int wmain(int argc, WCHAR* argv[])
{
USES_CONVERSION;
static const DWORD dwVersion = { 1 };
ULONG ulNumWords = 0;
HRESULT hr = S_OK;

//--- Check args
if( argc != 4 )
{
printf( "%s", "Usage: > mkvoice [[in]word list file] [[out]voice file] [voice name]\n" );
hr = E_INVALIDARG;
}
else
{
::CoInitialize( NULL );

//--- Open word list file and create output voice file
//--- _wfopen is not supported on Win9x, so use fopen.
FILE* hWordList = fopen( W2A(argv[1]), "r" );
FILE* hVoiceFile = fopen( W2A(argv[2]), "wb" );

if( hWordList && hVoiceFile )
{
//--- Write file version and leave space for word count
if( !fwrite( &dwVersion, sizeof(dwVersion), 1, hVoiceFile ) ||
fseek( hVoiceFile, 4, SEEK_CUR ) )
{
hr = E_FAIL;
}

//--- Get each entry
WCHAR WordFileName[MAX_PATH];
while( SUCCEEDED( hr ) && fgetws( WordFileName, MAX_PATH, hWordList ) )
{
ULONG ulTextLen = wcslen( WordFileName );
if( WordFileName[ulTextLen-1] == '\n' )
{
WordFileName[--ulTextLen] = NULL;
}
//--- Include NULL character when writing to the file
ulTextLen = (ulTextLen+1) * sizeof(WCHAR);

if( fwrite( &ulTextLen, sizeof(ulTextLen), 1, hVoiceFile ) &&
fwrite( WordFileName, ulTextLen, 1, hVoiceFile ) )
{
++ulNumWords;
//--- Open the wav data
ISpStream* pStream;
wcscat( WordFileName, L".wav" );
hr = SPBindToFile( WordFileName, SPFM_OPEN_READONLY, &pStream );
if( SUCCEEDED( hr ) )
{
CSpStreamFormat Fmt;
Fmt.AssignFormat(pStream);
if( Fmt.ComputeFormatEnum() == SPSF_11kHz16BitMono )
{
STATSTG Stat;
hr = pStream->Stat( &Stat, STATFLAG_NONAME );
ULONG ulNumBytes = Stat.cbSize.LowPart;

//--- Write the number of audio bytes
if( SUCCEEDED( hr ) &&
fwrite( &ulNumBytes, sizeof(ulNumBytes), 1, hVoiceFile ) )
{
BYTE* Buff = (BYTE*)alloca( ulNumBytes );
if( SUCCEEDED( hr = pStream->Read( Buff, ulNumBytes, NULL ) ) )
{
//--- Write the audio samples
if( !fwrite( Buff, 1, ulNumBytes, hVoiceFile ) )
{
hr = E_FAIL;
}
}
}
else
{
hr = E_FAIL;
}
}
else
{
printf( "Input file: %s has wrong wav format.", WordFileName );
}
pStream->Release();
}
}
else
{
hr = E_FAIL;
}
}
}
else
{
hr = E_FAIL;
}

//--- Write word count
if( SUCCEEDED( hr ) )
{
if( fseek( hVoiceFile, sizeof(dwVersion), SEEK_SET ) ||
!fwrite( &ulNumWords, sizeof(ulNumWords), 1, hVoiceFile ) )
{
hr = E_FAIL;
}
}

//--- Register the new voice file
// The section below shows how to programatically create a token for
// the new voice and set its attributes.
if( SUCCEEDED( hr ) )
{
CComPtr<ispobjecttoken> cpToken;
CComPtr<ispdatakey> cpDataKeyAttribs;
hr = SpCreateNewTokenEx(
SPCAT_VOICES,
argv[3],
&CLSID_SampleTTSEngine,
L"Sample TTS Voice",
0x409,
L"Sample TTS Voice",
&cpToken,
&cpDataKeyAttribs);

//--- Set additional attributes for searching and the path to the
// voice data file we just created.
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Gender", L"Male");
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Name", L"SampleTTSVoice");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Language", L"409");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Age", L"Adult");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Vendor", L"Microsoft");
}

//--- _wfullpath is not supported on Win9x, so use _fullpath.
CHAR szFullPath[MAX_PATH * 2];
if (SUCCEEDED(hr) && _fullpath(szFullPath, W2A(argv[2]), sizeof(szFullPath)/sizeof(szFullPath[0])) == NULL)
{
hr = SPERR_NOT_FOUND;
}

if (SUCCEEDED(hr))
{
USES_CONVERSION;
hr = cpToken->SetStringValue(L"VoiceData", A2W(szFullPath));
}
}
}

//--- Cleanup
if( hWordList )
{
fclose( hWordList );
}
if( hVoiceFile )
{
fclose( hVoiceFile );
}
::CoUninitialize();
}
return FAILED( hr );
}
AnswerRe: C++ Problems... Pin
toxcct5-Oct-05 23:31
toxcct5-Oct-05 23:31 
GeneralRe: C++ Problems... Pin
AndrewVos6-Oct-05 8:38
AndrewVos6-Oct-05 8:38 
GeneralRe: C++ Problems... Pin
AndrewVos6-Oct-05 8:43
AndrewVos6-Oct-05 8:43 
GeneralRe: C++ Problems... Pin
toxcct6-Oct-05 20:52
toxcct6-Oct-05 20:52 
Questionsimple question Pin
...---...3-Oct-05 10:14
...---...3-Oct-05 10:14 
AnswerRe: simple question Pin
MKlucher3-Oct-05 10:32
MKlucher3-Oct-05 10:32 
GeneralRe: simple question Pin
...---...3-Oct-05 11:06
...---...3-Oct-05 11:06 
AnswerRe: simple question Pin
MKlucher3-Oct-05 12:07
MKlucher3-Oct-05 12:07 
QuestionWin32 Pin
Tran Ngoc Minh2-Oct-05 0:13
Tran Ngoc Minh2-Oct-05 0:13 
AnswerRe: Win32 Pin
Iman_crte3-Oct-05 1:22
Iman_crte3-Oct-05 1:22 
Questionproject Pin
Anonymous1-Oct-05 22:33
Anonymous1-Oct-05 22:33 
AnswerRe: project Pin
Prakash Nadar3-Oct-05 15:23
Prakash Nadar3-Oct-05 15:23 
Questionproject in c++ Pin
gagit1-Oct-05 5:39
sussgagit1-Oct-05 5:39 
AnswerRe: project in c++ Pin
Prakash Nadar3-Oct-05 15:24
Prakash Nadar3-Oct-05 15:24 
QuestionWhy does integer work and not boolean Pin
LiquidE_SA1-Oct-05 4:40
LiquidE_SA1-Oct-05 4:40 
AnswerRe: Why does integer work and not boolean Pin
Matt Godbolt2-Oct-05 4:14
Matt Godbolt2-Oct-05 4:14 
AnswerRe: Why does integer work and not boolean Pin
AndrewVos5-Oct-05 19:35
AndrewVos5-Oct-05 19:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.