Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text To Speech Print statements in Python SDK - 1.40.0 #2610

Open
boyko11 opened this issue Oct 1, 2024 · 5 comments
Open

Text To Speech Print statements in Python SDK - 1.40.0 #2610

boyko11 opened this issue Oct 1, 2024 · 5 comments

Comments

@boyko11
Copy link

boyko11 commented Oct 1, 2024

After upgrading azure-cognitiveservices-speech to 1.40.0, in FastAPI python app I see PRINTS in the prod logs:
Info: on_underlying_io_bytes_received: Close frame received
Info: on_underlying_io_bytes_received: closing underlying io.
Info: on_underlying_io_close_complete: uws_state: 6.

2024-10-01 08:09:48,983 - INFO - [text_to_speech_service_azure.py:78] - Synthesizing sentence: I'm doing well, thank you for asking.
Info: on_underlying_io_bytes_received: Close frame received
Info: on_underlying_io_bytes_received: closing underlying io.
Info: on_underlying_io_close_complete: uws_state: 6.
2024-10-01 08:09:49,567 - INFO - [text_to_speech_service_azure.py:78] - Synthesizing sentence: It's always nice to start the day with a friendly chat.
Info: on_underlying_io_bytes_received: Close frame received
Info: on_underlying_io_bytes_received: closing underlying io.
Info: on_underlying_io_close_complete: uws_state: 6.
2024-10-01 08:09:50,284 - INFO - [llm_service_abstract.py:77] - entire_llm_response: I'm doing well, thank you for asking. It's always nice to start the day with a friendly chat. What's on your agenda for today?
2024-10-01 08:09:50,286 - INFO - [text_to_speech_service_azure.py:78] - Synthesizing sentence: What's on your agenda for today?
Info: on_underlying_io_bytes_received: Close frame received
Info: on_underlying_io_bytes_received: closing underlying io.
Info: on_underlying_io_close_complete: uws_state: 6.

Using text-to-speech on a python web app:

    async def text_to_audio_stream(
        self, text: str, user_id: str
    ) -> AsyncGenerator[bytes, None]:
        await TimingUtil().enqueue_timing_event(
            TimingEventName.tts_sentence_received,
            user_id,
            time.time(),
            {"sentence": text},
        )

        logger.info("Synthesizing sentence: %s", text)
        synthesizer = speechsdk.SpeechSynthesizer(
            speech_config=self.speech_config, audio_config=None
        )

        ssml = self.ssml_string_template.format(
            voice_name=self.azure_config.speech_synthesis_voice_name,
            voice_speed_increase=self.azure_config.speech_synthesis_voice_speed_increase,
            text=text,
        )

        logger.debug(ssml)

        result = await asyncio.get_running_loop().run_in_executor(
            None,
            lambda _synthesizer=synthesizer, _ssml=ssml: _synthesizer.speak_ssml_async(  # type: ignore
                _ssml
            ).get(),
        )

        if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
            await TimingUtil().enqueue_timing_event(
                TimingEventName.tts_sentence_synthesized, user_id, time.time()
            )

            audio_data_stream = speechsdk.AudioDataStream(result)
            buffer_size = 4096

            while True:
                audio_bytes_buffer = bytes(buffer_size)
                audio_bytes_read = audio_data_stream.read_data(audio_bytes_buffer)
                logger.debug("%s bytes received.", audio_bytes_read)
                if audio_bytes_read == 0:
                    break
                yield audio_bytes_buffer[:audio_bytes_read]

        else:
            logger.warning("Speech synthesis possible fail: %s", result.reason)

After downgrading back to azure-cognitiveservices-speech = "1.37.0"
the prints disappeared:

2024-10-01 08:27:28,744 - INFO - [text_to_speech_service_azure.py:78] - Synthesizing sentence: Good to hear everything's under control, Boyko.
2024-10-01 08:27:29,481 - INFO - [text_to_speech_service_azure.py:78] - Synthesizing sentence: As for me, I'm here and ready to chat as always.
2024-10-01 08:27:30,225 - INFO - [llm_service_abstract.py:77] - entire_llm_response: Good to hear everything's under control, Boyko. As for me, I'm here and ready to chat as always. What would you like to talk about today?
2024-10-01 08:27:30,227 - INFO - [text_to_speech_service_azure.py:78] - Synthesizing sentence: What would you like to talk about today?

Could you please remove the prints or switch them over to logging? Could you also add a linter that detects prints before you push the code as a package. Thanks!

@boyko11
Copy link
Author

boyko11 commented Oct 1, 2024

The prints started appearing in 1.38.0:
image

Copy link

This item has been open without activity for 19 days. Provide a comment on status and remove "update needed" label.

@github-actions github-actions bot added the update needed For items that are in progress but have not been updated label Oct 21, 2024
@boyko11
Copy link
Author

boyko11 commented Oct 21, 2024

Tried the latest this morning - 1.41.1. The prints(or log statements) are still there. Please change them over to debug, or silence them in some other way so we can upgrade. Thanks!

@github-actions github-actions bot removed the update needed For items that are in progress but have not been updated label Oct 22, 2024
@ShadowStrikerJ
Copy link

Encountering the same issue with the speech to text recognizer, can't find any way to remove the logging statements

@yash-sprnklr
Copy link

Facing the same issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants