人工智慧相關資料整理(長期)
C# 微軟語音辨識/語音合成結合OpenAI ChatGPT 變成ai人工智慧管家
透過微軟azure上的語音服務,辨識麥克風傳入的聲音後將語音轉成文字
接著再把文字送到open ai api中的chatgpt 模型中取得回應內容
最後再將回應內容透過語音合成送出
參考:
Introducing ChatGPT and Whisper APIs
https://openai.com/blog/introducing-chatgpt-and-whisper-apis
openai api
https://platform.openai.com/docs/guides/chat
Betalgo.OpenAI.GPT3
https://www.nuget.org/packages/Betalgo.OpenAI.GPT3/6.7.0
https://github.com/betalgo/openai
chatGPT與line官方帳號結合 = line ai 小助理
OpenAI設計的ChatGPT問世後,很快的ai的使用人數破億。且chatgpt讓ai整個流行了起來~ 想說台灣最流行的通訊工具line,有沒有機會跟chatgpt串到一起,於是很快的用php以及.net core都串了一次。簡單明瞭~很易懂
分享關鍵的php,有問題歡迎line: superlevin 林壽山
$api_key = 'xxxxxxxxxx';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.openai.com/v1/completions',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . $api_key
],
CURLOPT_POSTFIELDS => json_encode([
'prompt' => $ask_question,
'model' => 'text-davinci-003',
'max_tokens' => 1000,
'temperature' => 0.3
])
]);
$response = curl_exec($curl);
$json = json_decode($response, true);
使用.net 搖控 DJI TELLO 無人機
看到DJI TELLO有SDK,幾個重點整理
1 使用的是UDP
2 IP是: 192.168.10.1
3 使用的PORT有 8889(指令) 8890(狀態) 11111(取得畫面)
程式碼大概就是
// 定義 IP
string DJIIP = "192.168.10.1";
//定義埠號
int DJIPort = 8889;
// 開啟
UdpClient udpClient = new UdpClient();
udpClient.Connect(DJIIP,DJIPort);
//
Byte[] sendCmdBytes = null;
sendCmdBytes = Encoding.UTF8.GetBytes(“takeoff”);
udpClient.Send(sendCmdBytes, sendCmdBytes.Length);
https://www.ryzerobotics.com/zh-tw
https://www.ryzerobotics.com/zh-tw/tello/downloads
C# ChatGPT取回後轉語音合成 將base64轉音檔
從ChatGPT的api,取得文件後,再透過語音合成轉為base64音檔念出。
台灣雅婷 https://www.yating.tw/zh/api-text-to-speech-zh/
雅婷文字轉語音 https://tts.yating.tw/
文件 https://developer.yating.tw/doc/tts-%E8%AA%9E%E9%9F%B3%E5%90%88%E6%88%90#%E7%AF%84%E4%BE%8B
後台: https://developer.yating.tw/zh-TW/dashboard
其他參考
https://ai.baidu.com/tech/speech/tts
https://aws.amazon.com/tw/polly/
https://tw.piliapp.com/text-to-speech/
https://azure.microsoft.com/zh-tw/products/cognitive-services/text-to-speech/#overview
https://cloud.google.com/text-to-speech?hl=zh-tw
https://azure.microsoft.com/zh-tw/products/cognitive-services/text-to-speech/
https://www.xfyun.cn/services/online_tts
https://everest-ai.ximalaya.com/charm-studio/
static void DecodeBase64ToFile(string Base64String, string filenames)
{
try
{
byte[] bytes = Convert.FromBase64String(Base64String);
using (var fs = new FileStream(filenames, FileMode.Create, FileAccess.Write))
{
fs.Write(bytes, 0, bytes.Length);
fs.Flush();
}
}
catch (Exception e)
{
}
}
受保護的內容: c# 重構/技術/微服務
C#資料結構與演算法
使用對的演算法與資料結構,在程式效能上有很大的幫助。常用的資料結構有array、stack、 queue、 linked list、 tree、 graph、 heap、 hash。在c#上常見的是使用array 、arraylist、 list、 dictonary 以及queue可以滿足絕大部份的場景。
以下介紹github上二個高階資料結構與演算法的項目。
一、C Sharp Algorithms
一開始是學習資料結構,在不斷更新以及維護後,可以用在正式環境。
https://github.com/aalhour/C-Sharp-Algorithms
二、Advanced Algorithms
Nginx 視覺化管理工具
https://github.com/onlyGuo/nginx-gui
https://nginx.org/
首先先安裝 nginx,下載nginx後解壓縮,修改conf目錄下的 nginx.conf把listen改掉需要的port
然後 cmd start nginx.exe 就可以
停止的話 nginx.exe -s stop
重新載入設定則為 nginex.exe -s reload
nginx-gui解壓後
修改 conf/conf.properties
指定完路徑後,可以用startup.bat打開 shutdown.bat 停止
預設的port是 8889 ,帳密都是admin
透過前端程式開啟檔案的方式
一、 tag a
<a href=”” download=””>download</a>
or
const taga = document.createElement(“a)
taga.href= “”
taga.download = “”
taga.click()
這邊的download屬性是html5加上的,如果沒有指定的話就會依照content-disposition確定,再沒有的話就依url 最後request的部份
2 window.open
window.open(”,’_blank’)
or
window.open(”,’_blank’,’download=’)
3 location.href/location.assign/location.replace/location.reload
與window.open一樣
4 XMLHttpRequest
就是ajax,與axios、fetch相同
const xhr= new XMLHttpRequest()
xhr.open(‘GET’,”)
xhr.send()
xhr.onload = function(){
const blob = new Blob([xhr.reponse],(type:”})
const a = document.createElement(‘a’)
a.href= URL.createObjectURL(blob)
…..
}