Created
March 22, 2019 02:57
-
-
Save kokeiro001/852f01d342ebd14ccc1e8e35daa0af3c to your computer and use it in GitHub Desktop.
GoogleCloudSpeechを使って、音声ファイルをテキストに変換する機能を使ってみる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp1.1</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<Compile Remove="voice\**" /> | |
<EmbeddedResource Remove="voice\**" /> | |
<None Remove="voice\**" /> | |
</ItemGroup> | |
<ItemGroup> | |
<PackageReference Include="Google.Cloud.Speech.V1" Version="1.0.0-beta09" /> | |
</ItemGroup> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Google.Cloud.Speech.V1; | |
using System; | |
using System.Linq; | |
using System.Diagnostics; | |
namespace GoogleCloudSpeechSandbox.ConsoleApp | |
{ | |
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var speech = SpeechClient.Create(); | |
var response = speech.Recognize(new RecognitionConfig() | |
{ | |
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16, | |
LanguageCode = "ja-JP", | |
}, | |
RecognitionAudio.FromFile("voice/voice.wav")); | |
foreach (var result in response.Results) | |
{ | |
var array = result.Alternatives.ToArray(); | |
foreach (var alternative in array) | |
{ | |
Debug.WriteLine(alternative.Transcript); | |
Console.WriteLine(alternative.Transcript); | |
} | |
} | |
Console.WriteLine("Finish."); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment