-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a65c22a
commit 42de811
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
from elevenlabs.client import AsyncElevenLabs, ElevenLabs | ||
|
||
from .utils import DEFAULT_VOICE_FILE | ||
|
||
DEFAULT_EXT_AUDIO = "https://storage.googleapis.com/eleven-public-cdn/audio/marketing/nicole.mp3" | ||
|
||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_stt_convert(): | ||
"""Test basic speech-to-text conversion.""" | ||
client = ElevenLabs() | ||
|
||
audio_file = open(DEFAULT_VOICE_FILE, "rb") | ||
|
||
transcription = client.speech_to_text.convert( | ||
file=audio_file, | ||
model_id="scribe_v1" | ||
) | ||
|
||
assert isinstance(transcription.text, str) | ||
assert len(transcription.text) > 0 | ||
assert isinstance(transcription.words, list) | ||
assert len(transcription.words) > 0 | ||
|
||
@pytest.mark.asyncio | ||
async def test_stt_convert_as_stream(): | ||
"""Test speech-to-text conversion as stream.""" | ||
client = AsyncElevenLabs() | ||
|
||
audio_file = open(DEFAULT_VOICE_FILE, "rb") | ||
|
||
stream = client.speech_to_text.convert_as_stream( | ||
file=audio_file, | ||
model_id="scribe_v1" | ||
) | ||
|
||
transcription_text = "" | ||
async for chunk in stream: | ||
assert isinstance(chunk.text, str) | ||
transcription_text += chunk.text | ||
|
||
assert len(transcription_text) > 0 |