Skip to content

Commit 8a60f33

Browse files
committed
docs: update volume metering example
1 parent 1d99560 commit 8a60f33

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,15 @@ You can use the `volumeChangeEventOptions.enabled` option to enable volume meter
551551
See: [VolumeMeteringAvatar.tsx](https://github.com/jamsch/expo-speech-recognition/tree/main/example/components/VolumeMeteringAvatar.tsx) for a complete example that involves using `react-native-reanimated` to animate the volume metering.
552552

553553
```tsx
554-
import { ExpoSpeechRecognitionModule } from "expo-speech-recognition";
554+
import { Button } from "react-native";
555+
import {
556+
ExpoSpeechRecognitionModule,
557+
useSpeechRecognitionEvent,
558+
} from "expo-speech-recognition";
555559

556-
function VolumeMeteringAvatar() {
560+
function VolumeMeteringExample() {
557561
useSpeechRecognitionEvent("volumechange", (event) => {
562+
// a value between -2 and 10. <= 0 is inaudible
558563
console.log("Volume changed to:", event.value);
559564
});
560565

@@ -563,17 +568,13 @@ function VolumeMeteringAvatar() {
563568
lang: "en-US",
564569
volumeChangeEventOptions: {
565570
enabled: true,
571+
// how often you want to receive the volumechange event
566572
intervalMillis: 300,
567573
},
568574
});
569575
};
570576

571-
return (
572-
<View>
573-
<Button title="Start" onPress={handleStart} />
574-
<Text>Volume: {volume}</Text>
575-
</View>
576-
);
577+
return <Button title="Start" onPress={handleStart} />;
577578
}
578579
```
579580

0 commit comments

Comments
 (0)