2012年12月3日 星期一

Speech SDK 語音辨識範例

1. OS: Windows 7 x64
2. Tools: VS 2010
               Speech SDK x64 (Install Runtime, SDK and then TTS SR zh-TW)
3.

<Grid>
        <Ellipse Name="OO" Margin="0,0,0,0" Stroke="Red" StrokeThickness="20" Visibility="Hidden"/>
        <Grid Name="XX" Margin="0,0,0,0" Visibility="Hidden" >
            <Line Stroke="Blue" StrokeThickness="20" X1="0" Y1="0" X2="525" Y2="350"/>
            <Line Stroke="Blue" StrokeThickness="20" X1="0" Y1="350" X2="525" Y2="0"/>
        </Grid>
  </Grid>
4.

// 1. Add Ref Microsoft Speech Object Library v 11 Not in COM
// C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly\Microsoft.Speech.dll
using Microsoft.Speech.Recognition;

namespace WPFOX1
{
    /// <summary>
    /// MainWindow.xaml 的互動邏輯
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Create a new SpeechRecognitionEngine instance.
            SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("zh-TW"));
            // SpeechRecognitionEngine sre = new SpeechRecognitionEngine();

            // Create a simple grammar that recognizes "red", "green", or "blue".
            Choices colors = new Choices();
            colors.Add("對");
            colors.Add("是");
            colors.Add("圈");
            colors.Add("錯");
            colors.Add("差");
            colors.Add("不對");
           
            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);

            // Create the actual Grammar instance, and then load it into the speech recognizer.
            Grammar g = new Grammar(gb);
            sre.LoadGrammar(g);

            // Register a handler for the SpeechRecognized event.
            sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
            sre.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(sre_SpeechRecognitionRejected);
            sre.SetInputToDefaultAudioDevice();
            sre.RecognizeAsync(RecognizeMode.Multiple);
        }

        void sre_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
        {
            this.Title = e.ToString();
        }

        void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //this.Title = e.ToString();
            switch (e.Result.Text)
            {
                case "對":
                case "是":
                case "圈":
                    OO.Visibility = System.Windows.Visibility.Visible;
                    XX.Visibility = System.Windows.Visibility.Hidden;
                    break;
                case "錯":
                case "差":
                case "不對":
                    OO.Visibility = System.Windows.Visibility.Hidden;
                    XX.Visibility = System.Windows.Visibility.Visible;
                    break;
                default:
                    OO.Visibility = System.Windows.Visibility.Hidden;
                    XX.Visibility = System.Windows.Visibility.Hidden;
                    break;
            }
        }
    }
5 結果




2012年11月23日 星期五

Expression Encoder SDK Ex1

1. OS and Tools : Windows 8 + Expression 4 + VS2012
2. Sample code @
    C:\Program Files (x86)\Microsoft Expression\Encoder 4\SDK\Samples\Live
3. This program send a video (file) streaming into localhost:8080
4. Copy Wildlife.wmv into the same directory as live.exe
5. live Wildlie.wmv nd open the IE with url as mms://localhost:8080/

2012年10月26日 星期五

FileTracker:error FTK1011

Ref: http://www.dotblogs.com.tw/ricochen/archive/2010/06/15/15889.aspx

1. Download 3DTools souce code.
2. System: Mac Pro: VM : Windows 7 x64
    Tools: VS 2010
3. Open demo project with FileTracker error.
4. Solve problem by changing compiler from .net framework 3.0 to 4.0 as described in ref.

2012年10月23日 星期二

xbox controller test 2 (C#)

0-1 Hardware : ASUS A43S
0-2 OS: Windows 7 (x64)
0-3 Tools: VS 2010 (x86)
       - 1. XBox Controller Driver
              http://www.microsoft.com/hardware/en-us/d/xbox-360-wireless-controller-for-windows
       - 2. SlimDX x86 Runtime
              http://slimdx.org/download.php
1. using SlimDX.DLL (Downloadable)
2. Employ controls.cs from the example of the previous program.
3. using Xbox360Controller;
4. In the class of forms,

       GamepadState controls;
        Timer t1 = new Timer();
        private void Form1_Load(object sender, EventArgs e)
        {
            controls = new GamepadState(0);
            t1.Interval = 100;
            t1.Tick += new EventHandler(t1_Tick);
            t1.Start();
        }

        int i = 0;
        void t1_Tick(object sender, EventArgs e)
        {
            controls.Update();
            //this.Text = controls.LeftStick.Position.X.ToString() + ","
            //    + controls.LeftStick.Position.Y.ToString();
            //this.Text += (i++).ToString();
            if (controls.LeftStick.Position.X > 0.5) button1.Location = new Point(button1.Location.X + 10, button1.Location.Y);
            if (controls.LeftStick.Position.X < -0.5) button1.Location = new Point(button1.Location.X - 10, button1.Location.Y);
            if (controls.LeftStick.Position.Y > 0.5) button1.Location = new Point(button1.Location.X, button1.Location.Y-10);
            if (controls.LeftStick.Position.Y < -0.5) button1.Location = new Point(button1.Location.X, button1.Location.Y+10);
        }
5. All of the switches in the xbox controller can be read by a timer base event method();
6. Examples

XBOX360Controller Test

ref : http://visualcsharp.webs.com/projectdownloads.htm

1. Hardware: ASUS A43S, Microsoft wireless xbox controller
2. OS: Windows 8 (x64)
3. Tools: VS 2010(x86)

Download SlimDX (.NET4.0, x86) ** Notes x64 won't work.
http://slimdx.org/download.php


2012年9月30日 星期日

三球儀自轉公轉設定


三球儀公自轉設定(以WPF  3D Sphere 物件為例)
1.  腳本設定

<Grid.Triggers>
            <EventTrigger RoutedEvent="UserControl.Loaded" >
                <BeginStoryboard>
                    <Storyboard Name="myStoryBoard">
                        <DoubleAnimation
            Storyboard.TargetName="自轉"
            Storyboard.TargetProperty="Angle"
            From="0" To="360" Duration="0:0:1" RepeatBehavior="Forever"/>
                        <DoubleAnimation
            Storyboard.TargetName="公轉"
            Storyboard.TargetProperty="Angle"
            From="0" To="360" Duration="0:0:10" RepeatBehavior="Forever"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Grid.Triggers>
2.  自、公轉軸設定

<ModelVisual3D.Transform>
   <Transform3DGroup>
<!-- 先設定自轉軸  --!>
      <RotateTransform3D CenterX="0" CenterY="0" CenterZ="0">
                                    <RotateTransform3D.Rotation>
                                        <AxisAngleRotation3D  x:Name="自轉" Angle="0" Axis="0.3,1,0" />
                                    </RotateTransform3D.Rotation>
       </RotateTransform3D>
<!-- 平移公轉半徑 --!>
       <TranslateTransform3D OffsetX="3" OffsetY="0" OffsetZ="0"  />
<!-- 設定公轉軸--!>
       <RotateTransform3D>
                  <RotateTransform3D.Rotation>
                              <AxisAngleRotation3D  x:Name="公轉" Angle="0"   Axis="0,1,0" />
                   </RotateTransform3D.Rotation>
       </RotateTransform3D>
                            </Transform3DGroup>
 </ModelVisual3D.Transform>

2012年8月24日 星期五

VMM 2008 R2 PowerShell --- 1 (Domain Admin 權限)

1. 以網域管理者登入VMM主機,開啟PowerShell問題


載入延伸類型資料檔案時發生下列錯誤:
Microsoft.SystemCenter.VirtualMachineManager,C:\Program Files\Microsoft System
Center Virtual Machine Manager 2008 R2\bin\virtualmachinemanager.types.ps1xml :
檔案已因下列驗證例外狀況而被略過: C:\Program Files\Microsoft System Center Virtu
al Machine Manager 2008 R2\bin\virtualmachinemanager.types.ps1xml 檔案無法載入,
因為它的執行已遭軟體限制原則封鎖。如需詳細資訊,請連絡系統管理員。。

2. 問題
     Local administrator 登入,可以載入模組,但無法與VMM連線
     網域管理者可以連線,但無法載入模組
3. 重新建立網用使用者,加入網域管理者群組,工作正常。