Speech-to-text in react native [duplicate] - react-native

I am making a language app that records any new vocabulary a user is trying to learn. It would be great if users can add their words via a speech to text program, instead of having to enter it manually. I am having trouble achieving this task. I am aware that there is an API for apple but not android. Is there anyway possible of doing this, using an API? Like for instance, google speech to text API? But I guess I would first have to be able to access the device's microphone. I am a beginner and this would be very easy using the web. Is React Native still too young for this task?

You might wanna look at react-native-android-voice, a React Native module that supports speech-to-text for Android.
As #delkant mentioned, there's now also react-native-voice that supports both Android and iOS.
Alternatively, you can always write your custom native module using Android's SpeechRecognizer API. Here's a summary of all the classes and interfaces you might need for this task. If you are familiar with developing native Android apps, it's pretty easy to create a native module and bind it to your React Native project. Here's the official documentation of how to achieve this.

You also have react-native-voice
A speech-to-text library for React Native.
It supports android and iOS

The react-native-bluemix module provides both SpeechToText and TextToSpeech for React Native: https://github.com/pwcremin/react-native-bluemix
It wraps the Watson tools for both ios and android: https://github.com/watson-developer-cloud

React Native uses SFSpeechRecognizer under the hood for iOS which have various limitations : https://developer.apple.com/documentation/speech/sfspeechrecognizer
Be prepared to handle failures caused by speech recognition limits. Because speech recognition is a network-based service, limits are enforced so that the service can remain freely available to all apps. Individual devices may be limited in the number of recognitions that can be performed per day, and each app may be throttled globally based on the number of requests it makes per day. If a recognition request fails quickly (within a second or two of starting), check to see if the recognition service became unavailable. If it is, you may want to ask users to try again later.

Related

How to create a real life-like 3D avatar with react-native?

This question can sound a bit off-topic or more of tech capacity or capability. Let's say I am pretty new to this whole thing. I recently came across with https://avatarsdk.com and http://tada-time.com and really got curious how they are doing it. Let's say I want to use a real life-like 3D avatar in a react native app, any ideas where to start with? How do I create an avatar in React Native app?
I am well aware of there are API we can pay and use it.
Any help would be appreciated.
I guess what your requirement is to create 3D objects for Augmented reality, if I am correct. Currently Apple and Android provides their own framework for that. IOS's AR kit and android's AR Core is a bit different in terms of code structure(I mean how they approach problems, their functionality etc). I'll consider them a bit advance topic better done on native platforms. Answering your question, I haven't come across any such library in react native and I don't think we'll see any soon as react native is still maturing and still has a lot to do to become stable.
I've seen projects in react native having AR elements, but that was done entirely in native and bridged to react native (hybrid)

What is the difference between React Native and Flutter?

What is the difference between React-native and Flutter technically?
Both technologies seem to do relatively the same thing, and Flutter even admits that it takes inspiration from React: faq
This is even more obvious when they list the same features and have almost the same syntax (StatefulWidget vs Component class).
Similarly to AngularDart being a Dart implementation of Angular; is it right to assume that Flutter is a Dart implementation of React?
Architecturally, React Native (RN) and Flutter are very similar.
What Flutter calls a "Widget" is the strict equivalent to React's "Component". That's what Flutter means when it says its inspired from React.
The difference between them lies in the other aspects of the frameworks:
Interpreted Javascript VS Compiled Dart
Flutter uses Dart, a typed language that offers both "Just in time" (JIT) and "Ahead of time" (AOT) compilation (with tree-shaking included)
In development, Flutter uses JIT compilation to empower hot-reload. And for production builds, it uses AOT compilation for better performances.
React-Native uses Javascript enhanced by some syntax sugar called JSX.
JSX being a different language, it compiles to JS, then evaluated at runtime.
Bridge to native VS Complete rewrite
React native is built on the top of native.
When using a button or a text in React Native, you are manipulating the official object used for native Android/iOS apps.
We can consider React as a common language between Android/iOS to declare layouts – but fundamentally the applications are different with potential inconsistencies.
It's is not true cross-platform. But at the same time, it allows better interoperability with native elements.
Flutter is the opposite. The goal of Flutter is to use as few native elements as possible.
Flutter requests to the OS a window, and then entirely manage its content using Dart and Skia (it's c++ graphics engine).
It has a few implications:
All the UI logic had to be reimplemented by Flutter. Be it scroll, touch events, animations, ...
The application is written entirely in Dart, even deep into the lower layers. It means that whatever the platform is, it's always the same code that is executed.
Potentially anything that can run Dart code and create a window can run Flutter and apps should work with little to no change. As such, web is in progress ( Hummingbird) and basic support of desktops is available.
To some extent, we can compare Flutter to a webview/game engine, but optimized for casual applications.
Remi already has a couple good points. I have one more.
Interpreted with bridges - vs. native and no bridges
Despite what the name might imply, React Native apps are not compiled to native code. React Native apps interpret Javascript code during runtime, and component updates in a React Native app go through a bridge to the native view counterpart. This might slow things down a little bit and be a bottleneck.
On the contrary, Flutter apps (on release mode) are compiled to native code and don't require a bridge for manipulating the UI. This in turn, at least in theory, will be more performant - there's no need to do roundtrips to the native land to make simple UI changes. Not to mention that release Flutter code is natively compiled and there are no interpreters involved.
Dance monkey, dance
Now that we know that release mode Flutter apps don't have an interpreter or the need for bridges for UI manipulations, let's see what those two things actually are in the first place.
We'll do this with a highly hypothetical example app. Our React Native app has a button that makes a monkey dance on the screen. In React Native, our button and the dancing monkey components are written in Javascript and React.
Interpreters
Since Javascript is not a first class language on Android or iOS, your React Native app includes a Javascript interpreter that interprets your Javascript code in runtime. Without the interpreter, you wouldn't be able to write apps with Javascript at all - even a simple console.log('Hello World!') wouldn't work.
According to the React Native docs, in "most cases", the Javascript code will be interpreted with JavascriptCore.
Bridges
Under the hood, React Native uses the native Android Views and iOS UIViews for displaying UI components (such as dancing monkeys) on the screen. But since the UI parts of the Android and iOS SDKs don't use Javascript, you can't make the monkey dance by using Javascript alone.
This is where a bridge comes into play. On the other side of the bridge are your React Native components and logic, written in Javascript. On the opposite side, we have the host Android/iOS app that renders native views into the screen.
From now on, let's call the two sides of the bridge as the Javascript land and the native land.
So, what happens when the user clicks on our "dance, monkey, dance!" button?
The native Android/iOS view dispatches an onclick event, which goes over the bridge to the Javascript land.
Our onclick listener written in Javascript gets invoked. It is a simple call that toggles a boolean inside the component. Something along the lines of setState(() {isMonkeyDancing = true}) or similar.
React sees that something has changed. It comes up with an updated representation of UI elements that has a dancing monkey. The representation is just a tree of plain Javascript objects that describes the updated state of the UI.
The Javascript object tree gets serialized and sent over the bridge to the native land.
The host app receives the serialized object tree and deserializes it. Now it can update the native Android/iOS view to match the deserialized UI representation. Our monkey is now dancing and our user is eternally happy.
So in this example, one button click required going over the bridge two times.
Actually, it's three - just simply rendering a button initially is a call across the bridge itself.
In an app that is more than just one button and a dancing monkey, you're likely to go over the bridge a lot more. And every time you do, it requires serializing data and sending it over from one side to the another.
This is slower than just coming up with the UI representation and updating the UI with that directly. Additionally, there's a cost of interpreting Javascript in runtime compared to having the code compiled ahead of time.
The bottom line
Since Flutter is essentially a portable rendering engine, Flutter doesn't need a bridge to do an UI update. And because of that, UI updates, at least in theory, are faster. That's one reason why building apps with complex animations or things like Flare, SpriteWidget, or even games would be more lucrative with Flutter compared to React Native.
And because Flutter on release mode is AOT compiled, Flutter doesn't need an interpreter either. That's the difference between Flutter and React Native.
Flutter vs React Native: A Developer’s Perspective
React Native by Facebook and Flutter by Google – two hot cross-platform app development technologies creating a buzz. In this post, we will compare both of them in detail from a developer’s perspective.
What’s Flutter and React Native?
React Native is a project started by Facebook internally that they open-sourced in 2015. On the other side is Flutter, a project started by Google which they have been heavily promoting since I/O 2017. Both of these technologies help app developers build cross-platform apps faster by using a single programming language. React Native is already a mature tool and has a huge community, but Flutter also started seeing huge adoption rates since 2017. In this post, we will compare each of them using ten criteria:
Programming language
Technical architecture
Installation
Setup and project configuration
UI components and development API
Developer productivity
Community support
Testing support
Build & release automation support
DevOps and CI/CD support
Programming Language
The key benefit of using a cross-platform mobile app development technology is the ability to use a single programming language to develop apps for both iOS and Android.
React Native — JavaScript
Flutter — Dart
Installation
The installation method should be straightforward without having too many complicated steps so that it could be easily learned by developers that are just starting with it.
React Native - NPM
Flutter - Binary Download from Source
UI Components and Development API
React Native - Less Components
Flutter - Rich in Components
Conclusion
React Native and Flutter both have their pros and cons. Some of the industry experts have predicted that Flutter is the future of mobile app development. Considering the comparison above, it’s clear that Flutter has entered the cross-platform mobile development race very strongly. Let’s not predict the future but wait and watch!
If you learn both technology in deep. So, you will find big differences:
Programming language- Java Script and Dart
Technical architecture- Flex and Skia.
UI components and development API: Widget in flutter but views in React native.
Developer productivity: Debugging is very easy in Flutter.
Community: Big Community support in React Native.
Documentation & Toolkit: Flutter team have created simple duc for all widgets.
Testing support: Flutter providing testing libs.
DevOps and CI/CD: Flutter Providing CI/CD supports.
There are more difference between React Native and Flutter that you can read her.

Targeting both .ios.js and .android.js with a single platform-specific extension

I use react-native-web and share code between ios, android and web.
Is there any technique to target both iOS and Android platform with a single file, and at the same time not target web?
I know that the code below doesn't work, but serves as an example of what I have in mind:
Container.native.js
Container.web.js
so there two ways of having platform specific code in React Native as mentioned here. The method that you are referring to is mentioned here.
Remember that react-native-web is designed firstly to make react native code run on the web, so your designing Mobile first.
It's very easy. For the same example you have given, this is how you can do it:
Container.js // For mobile
Container.web.js // For Web
Also, you can always use Platform.OS for specific Platform specifications.
Hope it helps.

What actions you have taken after you hear about React Native Architecture Changing and Airbnb, Udacity abandon it?

This is not a technical question.
It just this is my first programming language which I am fluent and I don't want to abandon it. But I feel frustrated, I need to know about this framework, but should I learn something that will change in just a couple more weeks.
News:
https://adtmag.com/articles/2018/07/10/abandon-react-native.aspx
https://www.theregister.co.uk/2018/07/26/node_native_developers/
Few things from my perspective: Airbnb was supporting React Native since 2016, and recently they announced sunsetting React Native and reinvesting all of their efforts back into native because they weren’t able to achieve their specific goals. The reason why AirBnB is moving away from React Native is very specific to Airbnb. They already have a huge number of IOS & Android Developers and feel their application needs are pretty unconventional. They end up developing for 3 platforms instead of 2. Which means their entire application is not in React Native, only a few features are in React Native.
Read these articles: https://medium.com/braus-blog/airbnb-is-dropping-react-js-should-you-too-dcbff36def5c and Here goes what worked well and what didn’t : https://medium.com/airbnb-engineering/react-native-at-airbnb-the-technology-dafd0b43838 . And one head's up from the RN team after the .56 version release is "
We're working on a large-scale rearchitecture of React Native to make
the framework more flexible and integrate better with native
infrastructure in hybrid JavaScript/native apps. With this project,
we'll apply what we've learned over the last 5 years and incrementally
bring our architecture to a more modern one. We're rewriting many of
React Native's internals, but most of the changes are under the hood:
existing React Native apps will continue to work with few or no
changes."
Facebook has not stopped supporting React, and there are still a lot of contributors supporting and using React Native in the community. Moving away from technology depends on what are the other alternatives you have.

How do I access NFC capabilities using Flutter or React Native?

I'm trying to decide which language to learn so I can program an mobile app that revolves around NFC and your location. I heard Flutter and Reactive Native are two relatively new languages that allows you to write code for both iOS and Android and there's courses for them on Udemy. However when I Google searched "NFC Flutter" there wasn't any relevant articles on how to incorporate NFC. Is it worth learning either of the two languages or should I write my app separately in Swift and Java?
You can use either React Native or Flutter and still have NFC capabilities.
For Flutter there is this plugin you could try (haven't tested it myself)
For React Native you could use this plugin which is tested and works great
At the time of writing this answer there is no full solution for NFC in flutter.
That said, you can implement NFC functionality using PlatformChannels. Or, better, encapsulate in in a plugin.
That way, you can write a code for your app in dart for both platforms, but NFC functionality will call Native Swift or Java code to handle platform specifics.
Here is one plugin that is still Work in progress, that does the exact same thing for Android only. You could, for example, fork the plugin and add iOS code and there you would have full solution.