KoljaB / RealtimeSTT

A robust, efficient, low-latency speech-to-text library with advanced voice activity detection, wake word activation and instant transcription.
MIT License
2.09k stars 190 forks source link

openai.ChatCompletion no longer supported #19

Closed tfriedel closed 1 week ago

tfriedel commented 10 months ago

I ran tests\minimalistic_talkbot.py RealTimeSTT 0.1.8 RealTimeTTS 0.3.4 openai 1.6.0

I got this error:

RealTimeSTT: root - WARNING - error in play() with engine azure:

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

Traceback: Traceback (most recent call last): File "R:\projects\RealtimeSTT\test_env\lib\site-packages\RealtimeTTS\text_to_stream.py", line 308, in play for sentence in chunk_generator: File "R:\projects\RealtimeSTT\test_env\lib\site-packages\RealtimeTTS\text_to_stream.py", line 552, in _synthesis_chunk_generator for chunk in generator: File "R:\projects\RealtimeSTT\test_env\lib\site-packages\stream2sentence\stream2sentence.py", line 193, in generate_sentences for char in _generate_characters(generator, log_characters): File "R:\projects\RealtimeSTT\test_env\lib\site-packages\stream2sentence\stream2sentence.py", line 85, in _generate_characters for chunk in generator: File "R:\projects\RealtimeSTT\test_env\lib\site-packages\RealtimeTTS\threadsafe_generators.py", line 237, in next token = next(self.generator) File "R:\projects\RealtimeSTT\test_env\lib\site-packages\RealtimeTTS\threadsafe_generators.py", line 147, in next self._current_str = next(self._current_iterator) File "R:\projects\RealtimeSTT\tests\minimalistic_talkbot.py", line 11, in generate for chunk in openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages, stream=True): File "R:\projects\RealtimeSTT\test_env\lib\site-packages\openai\lib_old_api.py", line 39, in call raise APIRemovedInV1(symbol=self._symbol) openai.lib._old_api.APIRemovedInV1:

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

KoljaB commented 10 months ago

I am sorry, I didn't upgrade the test files so far.

Pls look here for an example of how to work with RealtimeTTS and the new OpenAI API.