コード例 #1
0
BOOL CTabSpeech::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_speech_supported = speech_init(); 

   	if(m_speech_supported == false) 
	{
		EnableWindow(FALSE);
		m_edit_box.SetWindowText("Speech API 5.1 not installed");
		m_checkbox_techroom.SetCheck(0);
		m_checkbox_briefings.SetCheck(0);
		m_checkbox_ingame.SetCheck(0);
	} else {
		m_edit_box.SetWindowText("Press play to test this string.");

#if FS2_SPEECH
		// Offer the user a choice of voices
		SpInitTokenComboBox( GetDlgItem(IDC_VOICE_COMBO )->GetSafeHwnd(), SPCAT_VOICES );
#endif

	}

	// Setup the volume
	m_volume_control.SetRange(0, 100);
	m_volume_control.SetPos(100);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #2
0
HRESULT CTTS::InitTokenList(HWND hWnd, BOOL bIsComboBox)
{
	if (bIsComboBox)
		return SpInitTokenComboBox(hWnd, SPCAT_RECOGNIZERS);
	else
		return SpInitTokenListBox(hWnd, SPCAT_RECOGNIZERS);
}
コード例 #3
0
BOOL CTTSApp::OnInitDialog( HWND hWnd )
/////////////////////////////////////////////////////////////////
{
    HRESULT                         hr          = S_OK;
        
    // Store this as the "Main Dialog"
    m_hWnd  = hWnd;

    // Add some default text to the main edit control
    SetDlgItemText( hWnd, IDE_EDITBOX, _T("Enter text you wish spoken here.") );

    // Set the event mask in the rich edit control so that it notifies us when text is
    // changed in the control
    SendMessage( GetDlgItem( hWnd, IDE_EDITBOX ), EM_SETEVENTMASK, 0, ENM_CHANGE );

    // Initialize the Output Format combo box
    int i;
    for( i=0; i<NUM_OUTPUTFORMATS; i++ )
    {
        SendDlgItemMessage( hWnd, IDC_COMBO_OUTPUT, CB_ADDSTRING, 0,
                    (LPARAM)g_aszOutputFormat[i] );

        SendDlgItemMessage( hWnd, IDC_COMBO_OUTPUT, CB_SETITEMDATA, i, 
                    (LPARAM)g_aOutputFormat[i] );
    }

    if ( !m_cpVoice )
    {
        hr = E_FAIL;
    }

    // Set the default output format as the current selection.
    if( SUCCEEDED( hr ) )
    {
        CComPtr<ISpStreamFormat> cpStream;
        HRESULT hrOutputStream = m_cpVoice->GetOutputStream(&cpStream);

        if (hrOutputStream == S_OK)
        {
            CSpStreamFormat Fmt;
            hr = Fmt.AssignFormat(cpStream);
            if (SUCCEEDED(hr))
            {
                SPSTREAMFORMAT eFmt = Fmt.ComputeFormatEnum();
                for( i=0; i<NUM_OUTPUTFORMATS; i++ )
                {
                    if( g_aOutputFormat[i] == eFmt )
                    {
                        m_DefaultFormatIndex = i;
                        SendDlgItemMessage( hWnd, IDC_COMBO_OUTPUT, CB_SETCURSEL, m_DefaultFormatIndex, 0 );
                    }
                }
            }
        }
        else
        {
            SendDlgItemMessage( hWnd, IDC_COMBO_OUTPUT, CB_SETCURSEL, 0, 0 );
        }
    }

    // Use the SAPI5 helper function in sphelper.h to initialize the Voice combo box.
    if ( SUCCEEDED( hr ) )
    {
        hr = SpInitTokenComboBox( GetDlgItem( hWnd, IDC_COMBO_VOICES ), SPCAT_VOICES );
    }
    
    if ( SUCCEEDED( hr ) )
    {
        SpCreateDefaultObjectFromCategoryId( SPCAT_AUDIOOUT, &m_cpOutAudio );
    }

    // Set default voice data 
    VoiceChange();

    // Set Range for Skip Edit Box...
    SendDlgItemMessage( hWnd, IDC_SKIP_SPIN, UDM_SETRANGE, TRUE, MAKELONG( 50, -50 ) );

    // Set the notification message for the voice
    if ( SUCCEEDED( hr ) )
    {
        m_cpVoice->SetNotifyWindowMessage( hWnd, WM_TTSAPPCUSTOMEVENT, 0, 0 );
    }

    // We're interested in all TTS events
    if( SUCCEEDED( hr ) )
    {
        hr = m_cpVoice->SetInterest( SPFEI_ALL_TTS_EVENTS, SPFEI_ALL_TTS_EVENTS );
    }

    // Get default rate and volume
    if( SUCCEEDED( hr ) )
    {
        hr = m_cpVoice->GetRate( &m_DefaultRate );
        // initialize sliders and edit boxes with default rate
        if ( SUCCEEDED( hr ) )
        {
            SendDlgItemMessage( hWnd, IDC_RATE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG( SPMIN_RATE, SPMAX_RATE ) );
            SendDlgItemMessage( hWnd, IDC_RATE_SLIDER, TBM_SETPOS, TRUE, m_DefaultRate );
            SendDlgItemMessage( hWnd, IDC_RATE_SLIDER, TBM_SETPAGESIZE, TRUE, 5 );
        }
    }

    if( SUCCEEDED( hr ) )
    {
        hr = m_cpVoice->GetVolume( &m_DefaultVolume );
        // initialize sliders and edit boxes with default volume
        if ( SUCCEEDED( hr ) )
        {
            SendDlgItemMessage( hWnd, IDC_VOLUME_SLIDER, TBM_SETRANGE, TRUE, MAKELONG( SPMIN_VOLUME, SPMAX_VOLUME ) );
            SendDlgItemMessage( hWnd, IDC_VOLUME_SLIDER, TBM_SETPOS, TRUE, m_DefaultVolume );
            SendDlgItemMessage( hWnd, IDC_VOLUME_SLIDER, TBM_SETPAGESIZE, TRUE, 10 );
        }
    }

    // If any SAPI initialization failed, shut down!
    if( FAILED( hr ) )
    {
        MessageBox( NULL, _T("Error initializing speech objects. Shutting down."), _T("Error"), MB_OK );
        SendMessage( hWnd, WM_CLOSE, 0, 0 );
        return(FALSE);
        
    }
    else
    {
        //
        // Create the child windows to which we'll blit our result
        //
        HWND hCharWnd = GetDlgItem(hWnd, IDC_CHARACTER);
        RECT rc;

        GetClientRect(hCharWnd, &rc);
        rc.left = (rc.right - CHARACTER_WIDTH) / 2;
        rc.top = (rc.bottom - CHARACTER_HEIGHT) / 2;
        m_hChildWnd = CreateWindow( CHILD_CLASS, NULL, 
                            WS_CHILDWINDOW | WS_VISIBLE,
                            rc.left, rc.top,
                            rc.left + CHARACTER_WIDTH, rc.top + CHARACTER_HEIGHT,
                            hCharWnd, NULL, m_hInst, NULL );

        if ( !m_hChildWnd )
        {
            MessageBox( hWnd, _T("Error initializing speech objects. Shutting down."), _T("Error"), MB_OK );
            SendMessage( hWnd, WM_CLOSE, 0, 0 );
            return(FALSE);
            
        }
        else
        {
            // Load Mouth Bitmaps and use and ImageList since we'll blit the mouth
            // and eye positions over top of the full image
            g_hListBmp = InitImageList();
        }
    }
    return(TRUE);
    
}
コード例 #4
0
ファイル: VoiceSetup.cpp プロジェクト: MXControl/RoboMX
BOOL CVoiceSetup::OnInitDialog(void)
{
	
	CDialog::OnInitDialog();
	
	HRESULT                             hr = S_OK;

	/*hr = SpEnumTokens(SPCAT_VOICES, NULL, NULL, &cpEnum);
	
	if(SUCCEEDED(hr)){

		hr = cpEnum->GetCount(&ulCount);

	}

	while(SUCCEEDED(hr) && ulCount -- ){
    
		cpVoiceToken.Release();
		if(SUCCEEDED(hr))
			hr = cpEnum->Next( 1, &cpVoiceToken, NULL );
		if(SUCCEEDED(hr))
	        hr = cpVoice->SetVoice(cpVoiceToken);
	    if(SUCCEEDED(hr))
			hr = cpVoice->Speak( L"How are you?", SPF_DEFAULT, NULL);

		m_cbMaleVoice.AddString(
	}  */


	hr = SpInitTokenComboBox(GetDlgItem(IDC_MALE_VOICE)->m_hWnd, SPCAT_VOICES);
	if(FAILED(hr)){

		AfxMessageBox("Error enumerating voices", MB_ICONSTOP);
	}

	hr = SpInitTokenComboBox(GetDlgItem(IDC_FEMALE_VOICE)->m_hWnd, SPCAT_VOICES);
	if(FAILED(hr)){

		AfxMessageBox("Error enumerating voices", MB_ICONSTOP);
	}


	CFileFind finder;

	BOOL bFound = finder.FindFile(g_sSettings.GetWorkingDir() + "\\gfx\\char_*.bmp");
	CString strChar, strTmp;
	while(finder.FindNextFile()){

		strChar = finder.GetFileTitle();
		strChar = strChar.Mid(5);
		m_cbMaleChar.AddString(strChar);
		m_cbFemChar.AddString(strChar);
	}


	CIni ini;
	ini.SetIniFileName(g_sSettings.GetIniFile());

	int nCnt = ini.GetValue("Voice", "MaleCount", 0);
	for(int i = 0; i < nCnt; i++){

		strTmp.Format("Male_%d", i);
		m_lbMales.AddString(ini.GetValue("Voice", strTmp, ""));
	}

	nCnt = ini.GetValue("Voice", "FemaleCount", 0);
	for(int i = 0; i < nCnt; i++){

		strTmp.Format("Female_%d", i);
		m_lbFemales.AddString(ini.GetValue("Voice", strTmp, ""));
	}



	return TRUE;
}