2011年1月6日 星期四

[雜談] 金嗓犀利哥 - Ted Williams , Homeless man , golden Voice



這篇文章不是在說棒球之神 Ted Williams 喔 , 而是在說在路邊毛遂自薦自己聲音而引發全球關注的 Ted Williams , 他是一個無家可歸但是擁有天籟之聲的街友 , 很幸運的是 , 他獲得了一份工作 , 是由NBA球隊 - 克里夫蘭騎士隊所提供的兩年合約 , 因為當初他就是在 Columbus, Ohio 這個地方被注意到的 , 而克里夫蘭騎士隊也是位於這個州  , 這邊有一篇關於他獲得這份工作的新聞 , 而在FaceBook上還有人替他成立了一個名為"Help Get Ted Williams a Voiceover Job"的社團 , So cool~~~~~~~






天那....他的聲音真的太好聽了吧!!!





這是 Ted Williams接受CBS連線訪問的片段



2011年1月4日 星期二

[Music] "得閒炒飯"主題曲 , 李安琪 - You're the One





導  演:許鞍華
演  員:吳君如、周慧敏、張兆輝、陳偉霆、萬綺雯、谷祖琳



前陣子看了許鞍華導演的"得閒炒飯"這部電影 , 但是老實說會看純粹是因為周慧敏的關係 , 因為小時候是電視兒童所以常常在港片中看到她 , 覺得她眼睛大大的又很漂亮 , 已經很久沒有她的消息了 , 沒想到她復出之後拍了這部電影 , 好奇心驅使就看看了 , 其實還是看得出來有點歲月的痕跡不過還是無損她的美麗 , 再來就是另一位"女主角吳君如" , 每次看到她我就會想到她早期拍港片的造型....她才真的是變化最多的....另外這部電影也可以還可以看到萬綺雯 , 我對她印象最深刻的就是她演的我和殭屍有個約會的馬小玲 , 至於這部電影的題材所呈現的社會問題和感情關係也是蠻值得省思的





不過吳君如的中性打扮我早在"四個好色的女人"中的Frankie見識到了




真的覺得周慧敏和國企匡長的很像




是不是差很多啊??? 隔壁是黃光亮 呵呵




深情....但是我忘記哪部片了




拍謝離題了....這部片的配樂還不錯 , 尤其是鋼琴的部分 , 而我要分享的是他的主題曲




李安琪 - You're the One

You're the one and only now I see
I should've known before but it's never too late for me
Remember all those momennts from long ago
And now that you are back
I'm never gonna let you go
Let me say let me pray once more
I'm never gonna weep
I love you very deep
Say again tell me now tell me how once more
How could you be that way  how could you live a day away
But i say honestly you're the one.
You gonna stay with me
You gotta stay and see 
Every little thing that counts for you and me
You gotta say
I gotta say
Without you I don't know how to live.

You're the one and only now I see
I should've known before but it's never too late to be
Without you I have nowhere else to run
Now I realize we're like the moon and sun
Now I realize that all along You're the one


2011年1月3日 星期一

[Android] 如何藉由Cell ID 和 Location Area Code 取得經緯度座標 (How to get Cell ID and Location Area Code by Geolocation API)



在之前的文章 [Android] 如何使用Google Map 2.0 & 3.0 中有提到 , 當取得Cell Id 和LAC 之後可以透過 http://www.google.com/glm/mmap 這個API取得經緯度 , 不過在網路上關於這個API的Reference真的很少 , 根據目前我所蒐集的資料 , 只知道可以丟入Cell Id 和LAC 作為實際能影響經緯度的輸入參數 , 而網路上另外還有一個類似的API : Geolocation API , 這網頁有介紹API的Network Protocal , 描述了參數輸入的格式和回報輸出的經緯度格式 , 並針對每個參數做敘述 , 值得一提的是並不是每個參數都是必要輸入的。


另外可以看到如果使用字串來編排作為參數的輸入格式會相當的麻煩 , 在這篇文章會使用java 的 JSON物件來作為參數的輸入格式 , 而其中主要會影響輸出經緯度的輸入的參數為 cell_towers 和 wifi_towers , 有趣的是參數的內容都可以為多個 , 這樣可以增加輸出經緯度的準確度 , 這也是為什麼這個API是網路上比較多人使用的原因。


最後我們會使用TabWidget分頁來呈現要送出的參數和回應的資料 , 以下是程式碼的部分


import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.TabActivity;
import android.content.res.Configuration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import android.widget.TabHost;
import android.widget.TextView;


public class LocationTest extends TabActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mTabHost = getTabHost();
        //我們的TabWidgetListViewTest 是繼承 TabActivity的
        //所以這邊是透過他的method getTabHost()
        //來取得我們在main.xml中宣告的TabHost
         
        mTabHost.addTab(mTabHost.newTabSpec("tab_test1")
          //將Tab加入我們要的資料
          .setIndicator("Send JSON Object")
          //在Tab上標示名稱和加上Icon
          .setContent(R.id.LinearLayoutJSON));
                //Tab內容為main.xml檔案中宣告的ListView , 而ListView的內容我們先前已經處理好了
         
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Response").setContent(R.id.LinearLayoutRES));
                 
        mTabHost.setCurrentTab(0);
        //預設該顯示哪個Tab的資料
        
        InitialUI(); //初始化元件
        getInfo();   //取得mmc mnc的資訊    
        getLocation();
    }    
 
    int CellID , LAC , mcc , mnc;    
    double lat, lng;
    
    TelephonyManager TManager;   
    WifiManager WManager;
    GsmCellLocation GCLocation;
 TextView TextViewJSON , TextViewRES;
    
    private void getInfo()
 {
       Configuration CF = (Configuration) getResources().getConfiguration(); 
     if(CF != null)
     {
     mcc = CF.mcc;
       mnc = CF.mnc; 
     }
 }
    
    private void InitialUI()
    { 
      TextViewJSON = (TextView) findViewById(R.id.TextViewJSON);
      TextViewRES = (TextView) findViewById(R.id.TextViewRES);
      
   TManager = (TelephonyManager) this.getSystemService(this.TELEPHONY_SERVICE); 
   WManager = (WifiManager) this.getSystemService(this.WIFI_SERVICE);
    }
        
    private void getCellIdLAC()
    {  
   if(TManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM)
        { 
        GCLocation = (GsmCellLocation) TManager.getCellLocation();
        //String imei = TManager.getDeviceId();
        if (GCLocation != null)
           {          
         CellID = GCLocation.getCid();
                  LAC = GCLocation.getLac();
              }
           else TextViewRES.append("無法獲得 GsmCellLocation 物件");
        }
        else TextViewRES.append("這不是GSM手機"); 
   }
    
    private void getLocation()
    {
  // TODO Auto-generated method stub
     
       JSONObject Locationdata = null;
     
       try
       {
      JSONObject JSONholder = new JSONObject();
      
      JSONholder.put("version", "1.1.0");
      JSONholder.put("host", "Android");
      JSONholder.put("request_address", true); //需要回報地址
      JSONholder.put("home_mobile_country_code", mcc);
      JSONholder.put("home_mobile_network_code", mnc);
      JSONholder.put("radio_type", "gsm"); //string (gsm|cdma|wcdma)     
      JSONholder.put("address_language", "zh_TW"); //地址語言 
           
           JSONArray cellTowerArray = new JSONArray(); 
           //為了可以儲存多筆Cell Tower的資料
           getCellIdLAC(); //取得Cell ID 和 LAC的資料     
         
           JSONObject cellTowerData = new JSONObject();
           cellTowerData.put("cell_id", Integer.toString(CellID)); 
      cellTowerData.put("location_area_code", LAC); 
      cellTowerArray.put(cellTowerData); // 目前只放入一筆資料 
      JSONholder.put("cell_towers", cellTowerArray);      
     
      
      JSONArray wifiTowerArray = new JSONArray();       
           JSONObject wifiTowerData = new JSONObject();
               
           WifiInfo WI = WManager.getConnectionInfo(); //取得現在連線的AP資訊               
           wifiTowerData.put("mac_address", WI.getMacAddress());
            wifiTowerData.put("ssid", WI.getSSID());
            wifiTowerArray.put(wifiTowerData);
           
         JSONholder.put("wifi_towers", wifiTowerArray);
        
      TextViewJSON.setText(JSONholder.toString());
      //顯示參數的輸出格式
      
         String urlString = "http://www.google.com/loc/json";          
         DefaultHttpClient client = new DefaultHttpClient();
         HttpPost post = new HttpPost(urlString); //使用post協定           
         StringEntity se = new StringEntity(JSONholder.toString());
         post.setEntity(se);
         HttpResponse resp = client.execute(post);
         HttpEntity entity = resp.getEntity(); //取得API傳回的資料          
           
         String result = EntityUtils.toString(entity); //轉成字串格式
         
         JSONObject RESdata = new JSONObject(result);
         //以下為解析回報得資料
         Locationdata = (JSONObject) RESdata.get("location");
         lat = (Double) Locationdata.get("latitude");
           lng = (Double) Locationdata.get("longitude");          
           
           JSONObject Addressdata = (JSONObject) Locationdata.get("address");
           StringBuffer sb = new StringBuffer();
           sb.append(Addressdata.get("country")+" ");
           sb.append(Addressdata.get("postal_code")+" ");
           sb.append(Addressdata.get("region")+" ");
           sb.append(Addressdata.get("city")+" ");
           sb.append(Addressdata.get("street")+" ");          
           
           TextViewRES.setText(lng+","+lat+" "+sb.toString());
           TextViewRES.append("\n\n"+Locationdata.toString());
         
         }catch(Exception E)
         {
          E.printStackTrace();
          Log.v("Locaiton result", "SomethingWrong"); 
          TextViewRES.setText("SomethingWrong ");
          TextViewRES.append(lng+","+lat+" "+Locationdata.toString());
         }  
 }
 TabHost mTabHost;
}


再來是Layout檔


    
        
         
        
        
                
        
        
        
                
         
            
        
        
               
        
        
        
                
                  
        
                  
      

最後是AndroidManifest
    
        
            
                
                
            
        
    
    
 
 
 
  

最後就可以獲得經緯度和地址的資訊了 , 實作結果如下



這邊呈現出準備要送出的JSON物件裡的內容




這邊為回應的資料結果




相關文章:
[Android Tips] 如何使用Google Map 2.0 & 3.0

[Android Tips] 如何取得手機的Cell ID 和 Location Area Code


參考資料:
http://developer.clear.com/wiki/12/JSON_REST

2010年12月16日 星期四

[Android] 如何使用語音辨識功能 (Speech Recognition Method)



Android 是一個開放系統 , 所以可以在我們的應用程式中加入許多Google 的服務 , 例如這次的語音辨識服務 , 之前在這篇 : [Android] 如何使用Google Translate API 和 Spinner 製作翻譯機 也使用過翻譯服務 , 這個服務會使用到 RecognizerIntent , 而Google的語音搜尋程式通常都已經是先安裝在Android 的手機上了 , 可以透過 設定 > 應用程式 > 管理應用程式 做檢查 , 像遠傳小精靈IDEOS就安裝了TextToSpeech功能和語音搜尋功能。


Google為了讓語音辨識盡可能的準確 , 所以他分了很多語言模組 (Language Model) , 根據不同目的 , 不同的使用情況來使用 , 目前分了Free Form , 和 Web Search 兩個模組 , 前者適合長句子 , 後者適合短句子 , 而且是針對搜尋所會使用的詞彙去調整的 , 就端看程式人員認為該用在哪種情況囉。


Google的伺服器現在支援 , 英文 , 官方中文和日文 , 對於Free Form model 來說 , 英文版本有了最佳化 , 他們正開發更多的語言來支援這項服務 , 另外這個Method 模擬器沒辦法測試 , 下面的截圖是用IDEOS跑的。






請開啟網路 , 不然無法連線至伺服器


按下按鈕就等待使用者說話


辨識速度還蠻快的通常不到一秒


誤差很小喔


What......


講了幾個小數的運算 , 加減乘除沒出來



好玩 , 不過我是使用Free Form而最佳化目前只有英文 , 如果是用Web Search的話 , 中文的辨識度還蠻高的 , 雖然要連線但是我沒有註冊User-Permission , 程式碼就不貼啦 , 從這邊copy and paste就可以了 , Thanks Google!

2010年12月15日 星期三

[Smartphone] 遠傳小精靈 IDEOS



很感謝學長買了這隻遠傳小精靈 IDEOS給我當開發機 , 接下來要作的就是熟悉這個開發工具 , 在網路上查了他的評價不外乎就是....便宜很便宜 , 效能和配備中等 , 少了多點觸控是有點可惜 , 因為這個功能實在沒辦法靠模擬器測試出來 , 但是對照他的價錢來講已經是很不錯了 , 而且還附USB Driver光碟 , 這個Driver是可以讓我們開發的程式透過Eclipse呼叫手機直接來Debug的, 我當初還很擔心要去哪邊下載 , 以下是IDEOS的手機規格。




◎ HSDPA + GSM 四頻 850 / 900 / 1800 / 1900
◎ 直立式機身設計,3.5mm 標準耳機插孔
◎ 2.8 吋電容式觸控主螢幕、320 x 240 螢幕解析度、262000 萬色
可同時讓 5 個行動裝置連接上網
◎ 支援 Smart phone 服務
◎ 支援 FM 收音機
◎ 採用 Android 2.2 作業系統
◎ 內建重力感應器 / 光感感應器
◎ 內建 Qualcomm MSM7225-1 528MHz 處理器
◎ 320 萬畫素相機 (沒有補光燈 , 沒有自動對焦)
◎ 支援 3GP 影片錄製
◎ 支援 MID、MP3、M4A、AMR、AAC、AAC+、eAAC+ 音樂播放
◎ 支援 MPEG4、H.263、H.264 影片播放
◎ 支援 A2DP 藍牙 V2.1 傳輸
◎ 支援 GPS 衛星導航,Google Map
◎ 支援 WiFi 802.11b/g/n 無線網路

◎ 支援 HSDPA 7.2Mbps 網路連線速度
◎ 內建 512MB ROM / 256MB RAM 記憶體
◎ 可透過 microSD 記憶卡擴充 (最大可至 32GB)











再來附上一段宣傳短片







本來想拍幾張照片的 , 但是發現技術太差 , 拍得不好看的話 , 會不會被遠傳罵....哈

Google Analytics