Skip to content

Commit a1857bf

Browse files
committed
Reuse whisper code examples on main page
1 parent ea90796 commit a1857bf

File tree

5 files changed

+16
-47
lines changed

5 files changed

+16
-47
lines changed

site/src/components/image-generation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const ImageGeneration = () => {
1919
return (
2020
<Section.Container>
2121
<Section.Column>
22-
<Section.Title>Image generation API</Section.Title>
22+
<Section.Title>Image Generation API</Section.Title>
2323
<Section.Description>
2424
A user-friendly image generation API can be used with generative models to improve
2525
creative tools and increase productivity. For instance, it can be utilized in furniture

site/src/components/image-processing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const ImageProcessing = () => {
1818
return (
1919
<Section.Container>
2020
<Section.Column>
21-
<Section.Title>Image processing with Visual Language Models</Section.Title>
21+
<Section.Title>Image Processing with Visual Language Models</Section.Title>
2222
<Section.Description>
2323
An easy-to-use API for vision language models can power chatbots, AI assistants like
2424
medical helpers, and AI tools like legal contract creators.
Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,23 @@ import { ExploreCodeSamples } from '@site/src/components/GoToLink/explore-code-s
22
import { GoToDocumentation } from '@site/src/components/GoToLink/go-to-documentation';
33
import { LanguageTabs, TabItemCpp, TabItemPython } from '@site/src/components/LanguageTabs';
44
import { Section } from '@site/src/components/Section';
5-
import CodeBlock from '@theme/CodeBlock';
65

76
import 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+
911
const 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" />

site/src/components/text-generation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const TextGeneration = () => {
2121
return (
2222
<Section.Container>
2323
<Section.Column>
24-
<Section.Title>Text generation API</Section.Title>
24+
<Section.Title>Text Generation API</Section.Title>
2525
<Section.Description>
2626
An easy-to-use API for text generation can work with an LLM model to create chatbots, AI
2727
assistants like financial helpers, and AI tools like legal contract creators.

site/src/pages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Layout from '@theme/Layout';
44
import { ImageGeneration } from '../components/image-generation';
55
import { ImageProcessing } from '../components/image-processing';
66
import { Installation } from '../components/Installation/installation';
7-
import { SpeechToText } from '../components/speech-to-text';
7+
import { SpeechProcessing } from '../components/speech-processing';
88
import { TextGeneration } from '../components/text-generation';
99

1010
import styles from './index.module.css';
@@ -47,7 +47,7 @@ export default function Home(): JSX.Element {
4747
<Installation />
4848
<TextGeneration />
4949
<ImageGeneration />
50-
<SpeechToText />
50+
<SpeechProcessing />
5151
<ImageProcessing />
5252
</div>
5353
</Layout>

0 commit comments

Comments
 (0)