-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve output formats support (#39)
- improve support for output formats - add command line flag to list supported formats - streamline command line parsing for voices and formats
- Loading branch information
Showing
7 changed files
with
137 additions
and
66 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module SayIt.Formats | ||
|
||
open Microsoft.CognitiveServices.Speech | ||
open Microsoft.FSharp.Reflection | ||
open SayIt.Utils | ||
|
||
type FormatType = | ||
| Mp316khz32kbps | ||
| Mp316khz64kbps | ||
| Mp316khz128kbps | ||
| Mp324khz48kbps | ||
| Mp324khz96kbps | ||
| Mp324khz160kbps | ||
| Pcm8khz16b | ||
| Pcm16khz16b | ||
| Pcm24khz16b | ||
override this.ToString() = toString this | ||
static member FromString s = fromString<FormatType> s | ||
|
||
let getFormatId (format: FormatType) = | ||
match format with | ||
| Mp316khz32kbps ->SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3 | ||
| Mp316khz64kbps ->SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3 | ||
| Mp316khz128kbps-> SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3 | ||
| Mp324khz48kbps->SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3 | ||
| Mp324khz96kbps-> SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3 | ||
| Mp324khz160kbps -> SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3 | ||
| Pcm8khz16b-> SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm | ||
| Pcm16khz16b -> SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm | ||
| Pcm24khz16b-> SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm | ||
|
||
let listFormats() = | ||
let types = FSharpType.GetUnionCases typeof<FormatType> | ||
printfn "Shorthand -> Id pairs for supported output formats (see https://bit.ly/2UOjVpg):" | ||
for t in types do | ||
let id = getFormatId (FormatType.FromString(t.Name.ToLower())) | ||
printfn "%s -> %A" (t.Name.ToLower()) id |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<Version>0.3.0</Version> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Voices.fs" /> | ||
<Compile Include="Config.fs" /> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Argu" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.11.0" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<Version>0.3.0</Version> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Utils.fs" /> | ||
<Compile Include="Formats.fs" /> | ||
<Compile Include="Voices.fs" /> | ||
<Compile Include="Config.fs" /> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Argu" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.11.0" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module SayIt.Utils | ||
|
||
open Microsoft.FSharp.Reflection | ||
|
||
// Create discriminated unions from string - http://fssnip.net/9l | ||
let toString (x: 'a) = | ||
match FSharpValue.GetUnionFields(x, typeof<'a>) with | ||
| case, _ -> case.Name.ToLower() | ||
|
||
let fromString<'a> (s: string) = | ||
match FSharpType.GetUnionCases typeof<'a> |> Array.filter (fun case -> case.Name.ToLower() = s) with | ||
| [| case |] -> FSharpValue.MakeUnion(case, [||]) :?> 'a | ||
| _ -> failwith (s + " not recognized as a valid parameter.") |
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