diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..715fb85
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+*.suo
+*.user
+/packages/
+/TestResult/
+bin/
+obj/
\ No newline at end of file
diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config
new file mode 100644
index 0000000..67f8ea0
--- /dev/null
+++ b/.nuget/NuGet.Config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe
new file mode 100644
index 0000000..c41a0d0
Binary files /dev/null and b/.nuget/NuGet.exe differ
diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets
new file mode 100644
index 0000000..3f8c37b
--- /dev/null
+++ b/.nuget/NuGet.targets
@@ -0,0 +1,144 @@
+
+
+
+ $(MSBuildProjectDirectory)\..\
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+ $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
+
+
+
+
+ $(SolutionDir).nuget
+
+
+
+ $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
+ $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
+
+
+
+ $(MSBuildProjectDirectory)\packages.config
+ $(PackagesProjectConfig)
+
+
+
+
+ $(NuGetToolsPath)\NuGet.exe
+ @(PackageSource)
+
+ "$(NuGetExePath)"
+ mono --runtime=v4.0.30319 "$(NuGetExePath)"
+
+ $(TargetDir.Trim('\\'))
+
+ -RequireConsent
+ -NonInteractive
+
+ "$(SolutionDir) "
+ "$(SolutionDir)"
+
+
+ $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
+ $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
+
+
+
+ RestorePackages;
+ $(BuildDependsOn);
+
+
+
+
+ $(BuildDependsOn);
+ BuildPackage;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/VoiceTextWebAPI.Client.sln b/VoiceTextWebAPI.Client.sln
new file mode 100644
index 0000000..625d100
--- /dev/null
+++ b/VoiceTextWebAPI.Client.sln
@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{8A7F64CF-F75B-493F-A32A-84D378BF7113}"
+ ProjectSection(SolutionItems) = preProject
+ .nuget\NuGet.Config = .nuget\NuGet.Config
+ .nuget\NuGet.exe = .nuget\NuGet.exe
+ .nuget\NuGet.targets = .nuget\NuGet.targets
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoiceTextWebAPI.Client", "VoiceTextWebAPI.Client\VoiceTextWebAPI.Client.csproj", "{4359A4B5-6122-4B18-A72B-905BC380C46D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4359A4B5-6122-4B18-A72B-905BC380C46D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4359A4B5-6122-4B18-A72B-905BC380C46D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4359A4B5-6122-4B18-A72B-905BC380C46D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4359A4B5-6122-4B18-A72B-905BC380C46D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/VoiceTextWebAPI.Client/Emotion.cs b/VoiceTextWebAPI.Client/Emotion.cs
new file mode 100644
index 0000000..ec6939b
--- /dev/null
+++ b/VoiceTextWebAPI.Client/Emotion.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace VoiceTextWebAPI.Client
+{
+ public enum Emotion
+ {
+ Default,
+ Happiness,
+ Anger,
+ Sadness
+ }
+}
diff --git a/VoiceTextWebAPI.Client/EmotionLevel.cs b/VoiceTextWebAPI.Client/EmotionLevel.cs
new file mode 100644
index 0000000..e9ffe50
--- /dev/null
+++ b/VoiceTextWebAPI.Client/EmotionLevel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace VoiceTextWebAPI.Client
+{
+ public enum EmotionLevel
+ {
+ Default = 0,
+ Low = 1,
+ High = 2
+ }
+}
diff --git a/VoiceTextWebAPI.Client/LICENSE b/VoiceTextWebAPI.Client/LICENSE
new file mode 100644
index 0000000..41897f4
--- /dev/null
+++ b/VoiceTextWebAPI.Client/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) {{{year}}} {{{fullname}}}
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/VoiceTextWebAPI.Client/Properties/AssemblyInfo.cs b/VoiceTextWebAPI.Client/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..18510d4
--- /dev/null
+++ b/VoiceTextWebAPI.Client/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("VoiceTextWebAPI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct(".NET Clinet for VoiceText Web API")]
+[assembly: AssemblyCopyright("Copyright © J.Sakamoto 2014, MIT License")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("731cf40d-d365-4c5b-9d47-f7e5cbbefb1d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/VoiceTextWebAPI.Client/README.md b/VoiceTextWebAPI.Client/README.md
new file mode 100644
index 0000000..6e29fd4
--- /dev/null
+++ b/VoiceTextWebAPI.Client/README.md
@@ -0,0 +1,38 @@
+VoiceText WebAPI Client for .NET
+================================
+
+This is the clinet librray of HOYA Voice Text Web API for .NET.
+
+Istllation
+----------
+
+You can install via nuget.org **with pre-release switch.**
+
+ PM> Install-Package VoiceTextWebAPI.Client -pre
+
+Usage
+-----
+
+```CSharp
+using VoiceTextWebAPI.Client;
+...
+public async void btn_OnClick()
+{
+ var client = new VoiceTextClient
+ {
+ APIKey = "{your API key here.}",
+ Speaker = Speaker.Haruka,
+ Emotion = Emotion.Happiness,
+ EmotionLevel = EmotionLevel.High,
+ Volume = 50,
+ Speed = 120,
+ Pitch = 120
+ };
+ var bytes = await client.GetVoiceAsync("こんにちは。");
+ File.WriteAllBytes(".\\result.wav", bytes);
+}
+```
+
+License
+-------
+Copyright (c) 2014 @jsakamoto. Licensed under the MIT license.
\ No newline at end of file
diff --git a/VoiceTextWebAPI.Client/Speaker.cs b/VoiceTextWebAPI.Client/Speaker.cs
new file mode 100644
index 0000000..44e2eec
--- /dev/null
+++ b/VoiceTextWebAPI.Client/Speaker.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+
+namespace VoiceTextWebAPI.Client
+{
+ public enum Speaker
+ {
+ Show,
+ Haruka,
+ Hikari,
+ Takeru
+ }
+}
diff --git a/VoiceTextWebAPI.Client/VoiceTextClient.cs b/VoiceTextWebAPI.Client/VoiceTextClient.cs
new file mode 100644
index 0000000..ca04bc9
--- /dev/null
+++ b/VoiceTextWebAPI.Client/VoiceTextClient.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Http;
+using System.Runtime.Serialization.Json;
+using System.Text;
+using System.Threading.Tasks;
+using VoiceTextWebAPI.Client.Internal;
+
+namespace VoiceTextWebAPI.Client
+{
+ public class VoiceTextClient
+ {
+ public Speaker Speaker { get; set; }
+
+ public Emotion Emotion { get; set; }
+
+ public EmotionLevel EmotionLevel { get; set; }
+
+ public int Pitch { get; set; }
+
+ public int Speed { get; set; }
+
+ public int Volume { get; set; }
+
+ public string APIKey { get; set; }
+
+ public Uri APIEndPoint { get; set; }
+
+ public VoiceTextClient()
+ {
+ this.APIEndPoint = new Uri("https://api.voicetext.jp/v1/tts");
+ this.Speaker = Speaker.Haruka;
+ this.Emotion = Emotion.Default;
+ this.EmotionLevel = EmotionLevel.Default;
+ this.Pitch = 100;
+ this.Speed = 100;
+ this.Volume = 100;
+ }
+
+ public byte[] GetVoice(string text)
+ {
+ var httpClinet = CreateHttpClient();
+ var content = BuildHttpRequestContent(text);
+ var response = httpClinet.PostAsync(this.APIEndPoint, content).Result;
+ if (response.StatusCode != HttpStatusCode.OK) ThrowVoiceTextException(response);
+ var bytes = response.Content.ReadAsByteArrayAsync().Result;
+
+ return bytes;
+ }
+
+ //public async Task GetVoiceAsync(string text)
+ //{
+ // var httpClinet = CreateHttpClient();
+ // var content = BuildHttpRequestContent(text);
+ // var response = await httpClinet.PostAsync(this.APIEndPoint, content);
+ // if (response.StatusCode != HttpStatusCode.OK) ThrowVoiceTextException(response);
+ // var bytes = await response.Content.ReadAsByteArrayAsync();
+ // return bytes;
+ //}
+
+ public Task GetVoiceAsync(string text)
+ {
+ var httpClinet = CreateHttpClient();
+ var content = BuildHttpRequestContent(text);
+ var x = httpClinet.PostAsync(this.APIEndPoint, content)
+ .ContinueWith(t =>
+ {
+ var response = t.Result;
+ if (response.StatusCode != HttpStatusCode.OK) ThrowVoiceTextException(response);
+ return response.Content.ReadAsByteArrayAsync();
+ });
+ return x.Unwrap();
+ }
+
+ private HttpClient CreateHttpClient()
+ {
+ var httpClinet = new HttpClient();
+ httpClinet.DefaultRequestHeaders.Add(
+ "Authorization",
+ "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(this.APIKey)));
+ return httpClinet;
+ }
+
+ private FormUrlEncodedContent BuildHttpRequestContent(string text)
+ {
+ var param = new Dictionary {
+ {"text", text},
+ {"speaker", this.Speaker.ToString().ToLower()},
+ {"pitch", this.Pitch.ToString()},
+ {"speed", this.Speed.ToString()},
+ {"volume", this.Volume.ToString()},
+ };
+ if (this.Emotion != Emotion.Default)
+ {
+ param.Add("emotion", this.Emotion.ToString().ToLower());
+ }
+ if (this.EmotionLevel != EmotionLevel.Default)
+ {
+ param.Add("emotion_level", ((int)this.EmotionLevel).ToString());
+ }
+
+ var content = new FormUrlEncodedContent(param);
+ return content;
+ }
+
+ private static void ThrowVoiceTextException(HttpResponseMessage response)
+ {
+ var errResponse = new DataContractJsonSerializer(typeof(VoiceTextErrorResponse)).ReadObject(response.Content.ReadAsStreamAsync().Result) as VoiceTextErrorResponse;
+ throw new VoiceTextException(errResponse.error.message, response.StatusCode);
+ }
+ }
+}
diff --git a/VoiceTextWebAPI.Client/VoiceTextErrorResponse.cs b/VoiceTextWebAPI.Client/VoiceTextErrorResponse.cs
new file mode 100644
index 0000000..c7ea227
--- /dev/null
+++ b/VoiceTextWebAPI.Client/VoiceTextErrorResponse.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace VoiceTextWebAPI.Client.Internal
+{
+ public class VoiceTextErrorResponse
+ {
+ public class VoiceTextError
+ {
+ public string message { get; set; }
+ }
+
+ public VoiceTextError error { get; set; }
+ }
+}
diff --git a/VoiceTextWebAPI.Client/VoiceTextException.cs b/VoiceTextWebAPI.Client/VoiceTextException.cs
new file mode 100644
index 0000000..029505a
--- /dev/null
+++ b/VoiceTextWebAPI.Client/VoiceTextException.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace VoiceTextWebAPI.Client
+{
+ public class VoiceTextException : InvalidOperationException
+ {
+ public HttpStatusCode StatusCode { get; set; }
+
+ public VoiceTextException()
+ : base()
+ {
+ }
+
+ public VoiceTextException(string message, HttpStatusCode statusCode)
+ : base(message)
+ {
+ this.StatusCode = statusCode;
+ }
+ }
+}
diff --git a/VoiceTextWebAPI.Client/VoiceTextWebAPI.Client.csproj b/VoiceTextWebAPI.Client/VoiceTextWebAPI.Client.csproj
new file mode 100644
index 0000000..98658fd
--- /dev/null
+++ b/VoiceTextWebAPI.Client/VoiceTextWebAPI.Client.csproj
@@ -0,0 +1,78 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {4359A4B5-6122-4B18-A72B-905BC380C46D}
+ Library
+ Properties
+ VoiceTextWebAPI.Client
+ VoiceTextWebAPI.Client
+ v4.5
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+ OnBuildSuccess
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if "$(ConfigurationName)" == "Release" goto PACK
+goto END
+:PACK
+pushd "$(ProjectDir)"
+"$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Prop Configuration=Release;Platform=AnyCPU -o $(OutDir)
+:END
+
+
+
\ No newline at end of file
diff --git a/VoiceTextWebAPI.Client/VoiceTextWebAPI.Client.nuspec b/VoiceTextWebAPI.Client/VoiceTextWebAPI.Client.nuspec
new file mode 100644
index 0000000..48501d1
--- /dev/null
+++ b/VoiceTextWebAPI.Client/VoiceTextWebAPI.Client.nuspec
@@ -0,0 +1,27 @@
+
+
+
+ $id$
+ $version$-beta
+ $title$
+ J.Sakamoto
+ J.Sakamoto
+ https://github.com/jsakamoto/voicetext-webapi-client4net/blob/master/LICENSE
+ https://github.com/jsakamoto/voicetext-webapi-client4net
+
+ false
+ The Web API client of [HOYA Voice Text Web API](https://cloud.voicetext.jp/webapi) for .NET
+
+ This library is the client of [HOYA Voice Text Web API](https://cloud.voicetext.jp/webapi) for .NET.
+
+
+
+
+ voicetext,voice,speach
+
+