The script I'm about to give you is for a program the when you press a hot key you can speak and it puts the text in the field where the cursor is it also highlights whatever text it puts out and then if I press another hot key it lets me communicate with GPT to ask questions regarding the highlighted text or if I want to make edits it will do that to the highlighted text. This is using Google speech to text API and GPT API. Is there a better more advanced way to accomplish all of those things then using this scriptimport os
import io
import keyboard
import pyaudio
import wave
import threading
from google.cloud import speech_v1
from google.cloud.speech_v1 import enums
from google.cloud.speech_v1 import types
import openai
import pyperclip


# Replace with the path to your JSON file and API key
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = r"path/to/your/json/file.json"
openai.api_key = "your_api_key"


# Audio recording parameters
RATE = 16000
CHUNK = int(RATE / 10)


def transcribe_stream(audio_stream):
    """Transcribe the given audio stream."""

    client = speech_v1.SpeechClient()

    config = types.RecognitionConfig(
        encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
        sample_rate_hertz=RATE,
        language_code="en-US",
    )

    streaming_config = types.StreamingRecognitionConfig(
        config=config, interim_results=True
    )

    def request_generator(audio_stream):
        """Generator that yields audio chunks from a stream."""
        while True:
            data = audio