File size: 4,277 Bytes
f010f5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from key import KEY
from openai import OpenAI
from pathlib import Path
client = OpenAI(api_key=KEY)


audio_file = open(Path(__file__).parent / "saved_model" / "HELLO.mp3", "rb")
transcript = client.audio.transcriptions.create(
  model="whisper-1",
  file=audio_file,
  response_format="verbose_json",
  timestamp_granularities=["word"]
)
print(transcript)
print(transcript.to_json())

# ❯ /Users/user/models/WhisperReproduction/.venv/bin/python /Users/user/models/WhisperReproduction/main.py
# TranscriptionVerbose(duration=2.559999942779541, language='english', text='Hello, how are you?', segments=None, words=[TranscriptionWord(end=1.2799999713897705, start=0.800000011920929, word='Hello'), TranscriptionWord(end=1.7000000476837158, start=1.2799999713897705, word='how'), TranscriptionWord(end=1.7999999523162842, start=1.7000000476837158, word='are'), TranscriptionWord(end=2.0399999618530273, start=1.7999999523162842, word='you')], task='transcribe')

# /Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/pydantic/main.py:477: UserWarning: Pydantic serializer warnings:
#   Expected `str` but got `float` with value `2.559999942779541` - serialized value may not be as expected
#   return self.__pydantic_serializer__.to_json(
# {
#   "duration": 2.559999942779541,
#   "language": "english",
#   "text": "Hello, how are you?",
#   "words": [
#     {
#       "end": 1.2799999713897705,
#       "start": 0.800000011920929,
#       "word": "Hello"
#     },
#     {
#       "end": 1.7000000476837158,
#       "start": 1.2799999713897705,
#       "word": "how"
#     },
#     {
#       "end": 1.7999999523162842,
#       "start": 1.7000000476837158,
#       "word": "are"
#     },
#     {
#       "end": 2.0399999618530273,
#       "start": 1.7999999523162842,
#       "word": "you"
#     }
#   ],
#   "task": "transcribe"
# }

# audio_file = open(Path(__file__).parent / "saved_model" / "chatgpt_longest_ish.wav", "rb")
# transcript = client.audio.transcriptions.create(
#   model="whisper-1",
#   file=audio_file
# )
# Transcription(text='Hello, how are you?') second or less
# Transcription(text='...Of course, there's also computer animation, which has opened up endless possibilities for creativity. What's your favorite type of animation?') 4m 9s
# ❯ /Users/user/models/WhisperReproduction/.venv/bin/python /Users/user/models/WhisperReproduction/main.py
# Traceback (most recent call last):
#   File "/Users/user/models/WhisperReproduction/main.py", line 8, in <module>
#     transcript = client.audio.transcriptions.create(
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/resources/audio/transcriptions.py", line 188, in create
#     return self._post(  # type: ignore[return-value]
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1283, in post
#     return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 960, in request
#     return self._request(
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1049, in _request
#     return self._retry_request(
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1098, in _retry_request
#     return self._request(
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1049, in _request
#     return self._retry_request(
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1098, in _retry_request
#     return self._request(
#   File "/Users/user/models/WhisperReproduction/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1064, in _request
#     raise self._make_status_error_from_response(err.response) from None
# openai.APIStatusError: Error code: 413 - {'error': {'message': '413: Maximum content size limit (26214400) exceeded (26293319 bytes read)', 'type': 'server_error', 'param': None, 'code': None}}
# ~/models/WhisperReproduction main* 2m 5s   
# print(transcript)