Skip to content

Commit

Permalink
chore: add preview
Browse files Browse the repository at this point in the history
  • Loading branch information
jamsch committed Aug 15, 2024
1 parent f69c081 commit de3cde2
Show file tree
Hide file tree
Showing 12 changed files with 459 additions and 514 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ module.exports = {
},
rules: {
"import/order": "off",
"@typescript-eslint/array-type": "off",
},
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

expo-speech-recognition implements the iOS [`SFSpeechRecognizer`](https://developer.apple.com/documentation/speech/sfspeechrecognizer), Android [`SpeechRecognizer`](https://developer.android.com/reference/android/speech/SpeechRecognizer) and Web [`SpeechRecognition`](https://wicg.github.io/speech-api/) for React Native projects with the goal of code reuse across web and mobile.

<img src="./images/preview.jpg" width="240" alt="expo-speech-recognition preview" />
![expo-speech-recognition preview](./images/preview.gif)

## Installation

Expand Down
11 changes: 8 additions & 3 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ export default function App() {
]}
>
{Platform.OS === "android" && settings.requiresOnDeviceRecognition && (
<DownloadOfflineModel locale={settings.lang ?? "en-US"} />
<View style={styles.flex1}>
<DownloadOfflineModel locale={settings.lang ?? "en-US"} />
</View>
)}

{status === "idle" ? (
Expand Down Expand Up @@ -201,20 +203,23 @@ function DownloadOfflineModel(props: { locale: string }) {
.catch((err) => {
Alert.alert("Failed to download offline model!", err.message);
})
.finally(() => setDownloading(null));
.finally(() => {
setDownloading(null);
});
};

return (
<TouchableNativeFeedback
disabled={Boolean(downloading)}
onPress={handleDownload}
>
<View style={{ maxWidth: 200 }}>
<View>
<Text
style={{
fontWeight: "bold",
color: downloading ? "#999" : "#539bf5",
}}
adjustsFontSizeToFit
>
{downloading
? `Downloading ${props.locale} model...`
Expand Down
Loading

0 comments on commit de3cde2

Please sign in to comment.