Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Punctuation #355

Open
ilyakar opened this issue Oct 2, 2021 · 6 comments · May be fixed by #515
Open

Automatic Punctuation #355

ilyakar opened this issue Oct 2, 2021 · 6 comments · May be fixed by #515

Comments

@ilyakar
Copy link

ilyakar commented Oct 2, 2021

Is there a way to have the punctuation automatically added to the text? e.g., "question mark".

@mauricekenji
Copy link

+100. How might we get this functionality?

@DraghiciAdrian
Copy link

I am also looking for a solution for this. Any ideas?

@Tom-Standen
Copy link

Me too! Would be great for voice notes, longer dictations

@comontes
Copy link

@comontes
Copy link

comontes commented Jan 1, 2024

Ok, so using patch-package I changed:


diff --git a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
index fd9dad8..6f13745 100644
--- a/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
+++ b/node_modules/@react-native-voice/voice/ios/Voice/Voice.m
@@ -153,6 +153,11 @@ - (void) setupAndStartRecognizing:(NSString*)localeStr {
     // Configure request so that results are returned before audio recording is finished
     self.recognitionRequest.shouldReportPartialResults = YES;
 
+    // Configure request to add punctuation to speech recognition results.
+    if (@available(iOS 16.0, *)) {
+        self.recognitionRequest.addsPunctuation = YES;
+    }
+
     if (self.recognitionRequest == nil) {
         [self sendResult:@{@"code": @"recognition_init"} :nil :nil :nil];
         [self teardown];

Steps using Yarn:

  1. Install packages:
yarn add --dev patch-package postinstall-postinstall
  1. In package.json add a script:
 "scripts": {
+  "postinstall": "patch-package"
 }
  1. Modify file, open node_modules/@react-native-voice/voice/ios/Voice/Voice.m:

Add these lines after
self.recognitionRequest.shouldReportPartialResults = YES;

    // Configure request to add punctuation to speech recognition results.
    if (@available(iOS 16.0, *)) {
        self.recognitionRequest.addsPunctuation = YES;
    }

  1. Create patch file running:
yarn patch-package @react-native-voice/voice
  1. Build app again, I used eas build.

  2. Enjoy

@tigerjiang
Copy link

Is there any update? I want to get the proper punctuation on Android, Thanks

@danieloi danieloi linked a pull request Jul 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants