voice icon indicating copy to clipboard operation
voice copied to clipboard

Automatic Punctuation

Open ilyakar opened this issue 3 years ago • 6 comments

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

ilyakar avatar Oct 02 '21 18:10 ilyakar

+100. How might we get this functionality?

mauricekenji avatar May 04 '23 22:05 mauricekenji

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

DraghiciAdrian avatar May 08 '23 12:05 DraghiciAdrian

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

Tom-Standen avatar Sep 26 '23 20:09 Tom-Standen

I think this would help for iOS https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/3930023-addspunctuation

comontes avatar Dec 31 '23 22:12 comontes

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

comontes avatar Jan 01 '24 17:01 comontes

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

tigerjiang avatar Jan 02 '24 02:01 tigerjiang