Skip to content

Instantly share code, notes, and snippets.

View peted70's full-sized avatar
™️

Pete D peted70

™️
View GitHub Profile
#include <map>
#include <functional>
#include "sub_token.h"
using namespace std::placeholders;
using namespace std;
template <typename... Args>
class subject
{
future<shared_ptr<GraphNode>> RootPageViewModel::LoadFileAsync()
{
auto fop = ref new FileOpenPicker();
fop->FileTypeFilter->Append(".glb");
fop->FileTypeFilter->Append(".gltf");
auto file = co_await fop->PickSingleFileAsync();
if (file == nullptr)
co_return nullptr;
using (var httpClient = new HttpClient())
{
var response = await httpClient.GetAsync("https://dev.microsofttranslator.com/languages?api-version=1.0&scope=text,tts,speech");
response.EnsureSuccessStatusCode();
var jsonString = await response.Content.ReadAsStringAsync();
dynamic obj = JsonConvert.DeserializeObject(jsonString);
// Do some stuff with obj...
}
@peted70
peted70 / translator-api-auth.cs
Created February 17, 2018 13:01
auth with the Azure translator api
private async Task<string> GetTokenAsync()
{
string key = "--- YOUR API KEY HERE ---";// Environment.GetEnvironmentVariable("SKYPE_KEY");
if (string.IsNullOrEmpty(key))
{
Debug.Log("Please set an environment variable named 'SKYPE_KEY' to your Skype api key");
return string.Empty;
}
// First retrieve a time-restricted key to use to access the API (will need to write code
@peted70
peted70 / convert-audio.cs
Created February 17, 2018 10:57
Convert floating point audio data in the range -1.0 to 1.0 to signed 16-bit audio data and populate the provided stream
/// <summary>
/// Convert floating point audio data in the range -1.0 to 1.0 to signed 16-bit audio data
/// and populate the provided stream
/// </summary>
/// <param name="audioData"></param>
/// <param name="stream"></param>
/// <returns></returns>
int BufferConvertedData(float[] audioData, Stream stream)
{
// Can't just do a block copy here as we need to convert from float[-1.0f, 1.0f] to 16bit PCM
using System;
namespace MSHealthBot
{
public class Sleep
{
public Sleepactivity[] sleepActivities { get; set; }
public int itemCount { get; set; }
}