Skip to content

Commit

Permalink
Add ChineseChatMode option
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Feb 19, 2022
1 parent a7f569c commit b7da3ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Note: If your current input language is set to Chinese, you can select character
"UseMenuKey": false,
"SendTrailingEnter": false,
"SendTrailingSpace": false,
"ChineseChatMode": false,
"ShowListeningOverlay": true
}
```
Expand All @@ -65,6 +66,7 @@ Make sure to replace `<paste-your-subscription-key>` and `<paste-your-region>` t
- `UseMenuKey`: Determines whether the [menu/application key](https://en.wikipedia.org/wiki/Menu_key) (`≣ Menu`) can be used as `Alt+H`. (Make the key acts like a dedicated speech recognition key)
- `SendTrailingEnter`: Determines whether to send a trailing `enter` after sending inputs.
- `SendTrailingSpace`: Determines whether to send a trailing `space` after sending inputs.
- `ChineseChatMode`: Replaces Chinese comma (``) into English whitespace (` `), and removes Chinese period (``).
- `ShowListeningOverlay`: Determines whether to show an indicator microphone overlay window when the program is listening.

## Program Hint
Expand Down
11 changes: 10 additions & 1 deletion speech-to-windows-input/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Config
public bool UseMenuKey { get; set; } = false;
public bool SendTrailingEnter { get; set; } = false;
public bool SendTrailingSpace { get; set; } = false;
public bool ChineseChatMode { get; set; } = false;
public bool ShowListeningOverlay { get; set; } = true;
}
class Program
Expand Down Expand Up @@ -259,11 +260,19 @@ private static String GetCommonPrefix(String s1, String s2)
for (i = 0; i < min && s1[i] == s2[i]; i++) { }
return s1.Substring(0, i);
}
private static String PostProcessText(String text)
{
if (text == null)
return null;
if (config.ChineseChatMode)
return text.Replace(",", " ").Replace("。", "");
return text;
}
private static void QueueInput(String text)
{
if (cancelling)
return;
inputQueue.Enqueue(new Tuple<String, String>(partialRecognizedText, text));
inputQueue.Enqueue(new Tuple<String, String>(PostProcessText(partialRecognizedText), PostProcessText(text)));
}
// Copied directly from llc
private static llc.Natives.INPUT getInput(int key, bool down, bool unicode = false)
Expand Down

0 comments on commit b7da3ec

Please sign in to comment.