File size: 1,233 Bytes
6a191ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# import os
# from dotenv import load_dotenv
from groq import Groq

# Load environment variables from .env file
# load_dotenv()

# Initialize the Groq client
client = Groq(
    api_key='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',
)

def transcribe_audio(filename):
    """Transcribe the audio file and return the transcription text."""
    # Open the audio file
    with open(filename, "rb") as file:
        # Create a transcription of the audio file
        transcription = client.audio.transcriptions.create(
            file=(filename, file.read()),  # Required audio file
            model="whisper-large-v3",  # Required model to use for transcription
            prompt="",  # Optional
            response_format="json",  # Optional
            language="en",  # Optional
            temperature=0.0  # Optional
        )
        
        # Return the transcription text
        return transcription.text  # Access the 'text' property

# Example usage (you can remove this part later)
if __name__ == "__main__":
    filename = "/Users/sydneydu/Projects/ConcertBuddy/blankspacetrimmed.mp3"
    transcription_text = transcribe_audio(filename)
    print(transcription_text)  # Print the extracted text for testing