@@ -2,58 +2,23 @@ import { ExploreCodeSamples } from '@site/src/components/GoToLink/explore-code-s
22import { GoToDocumentation } from '@site/src/components/GoToLink/go-to-documentation' ;
33import { LanguageTabs , TabItemCpp , TabItemPython } from '@site/src/components/LanguageTabs' ;
44import { Section } from '@site/src/components/Section' ;
5- import CodeBlock from '@theme/CodeBlock' ;
65
76import ImagePlaceholder from '@site/static/img/image-generation-placeholder.webp' ;
87
8+ import CodeExampleCpp from '@site/docs/use-cases/speech-processing/_sections/_run_model/_code_example_cpp.mdx' ;
9+ import CodeExamplePython from '@site/docs/use-cases/speech-processing/_sections/_run_model/_code_example_python.mdx' ;
10+
911const FEATURES = [
1012 'Translate transcription to English' ,
1113 'Predict timestamps' ,
1214 'Process Long-Form (>30 seconds) audio' ,
1315] ;
1416
15- const pythonCodeBlock = (
16- < CodeBlock language = "python" >
17- { `import openvino_genai
18- import librosa
19-
20- def read_wav(filepath):
21- raw_speech, samplerate = librosa.load(filepath, sr=16000)
22- return raw_speech.tolist()
23-
24- device = "CPU" # GPU can be used as well
25- pipe = openvino_genai.WhisperPipeline("whisper-base", device)
26- raw_speech = read_wav("sample.wav")
27- print(pipe.generate(raw_speech))` }
28- </ CodeBlock >
29- ) ;
30-
31- const cppCodeBlock = (
32- < CodeBlock language = "cpp" >
33- { `#include <iostream>
34-
35- #include "audio_utils.hpp"
36- #include "openvino/genai/whisper_pipeline.hpp"
37-
38- int main(int argc, char* argv[]) {
39- std::filesystem::path models_path = argv[1];
40- std::string wav_file_path = argv[2];
41- std::string device = "CPU"; // GPU can be used as well
42-
43- ov::genai::WhisperPipeline pipeline(models_path, device);
44-
45- ov::genai::RawSpeechInput raw_speech = utils::audio::read_wav(wav_file_path);
46-
47- std::cout << pipeline.generate(raw_speech, ov::genai::max_new_tokens(100)) << '\\n';
48- }` }
49- </ CodeBlock >
50- ) ;
51-
52- export const SpeechToText = ( ) => {
17+ export const SpeechProcessing = ( ) => {
5318 return (
5419 < Section . Container >
5520 < Section . Column >
56- < Section . Title > Speech to text API</ Section . Title >
21+ < Section . Title > Speech Processing API</ Section . Title >
5722 < Section . Description >
5823 An intuitive speech-to-text API can work with models like Whisper to enable use cases such
5924 as video transcription, enhancing communication tools.
@@ -64,8 +29,12 @@ export const SpeechToText = () => {
6429 < Section . Features features = { FEATURES } />
6530 < hr />
6631 < LanguageTabs >
67- < TabItemPython > { pythonCodeBlock } </ TabItemPython >
68- < TabItemCpp > { cppCodeBlock } </ TabItemCpp >
32+ < TabItemPython >
33+ < CodeExamplePython />
34+ </ TabItemPython >
35+ < TabItemCpp >
36+ < CodeExampleCpp />
37+ </ TabItemCpp >
6938 </ LanguageTabs >
7039 < hr />
7140 < ExploreCodeSamples link = "docs/category/samples" />
0 commit comments