Spaces:
Runtime error
Runtime error
import openai | |
def get_embedding(text, model="text-embedding-ada-002"): | |
text = text.replace("\n", " ") | |
return openai.Embedding.create(input=[text], model=model)["data"][0]["embedding"] | |
def get_embeddings(text_lists, model="text-embedding-ada-002"): | |
res = openai.Embedding.create(input=text_lists, model=model)["data"] | |
return [r["embedding"] for r in res] | |
def whisper_transcription(file_path) -> str: | |
audio_file = open(file_path, "rb") | |
result = openai.Audio.transcribe( | |
model="whisper-1", | |
file=audio_file, | |
) | |
return result["text"] | |