`embed` and speech to text class

pull/55/head
Kye 1 year ago
parent 903eeeb1a0
commit 246a66640b

@ -0,0 +1,11 @@
# This file contains the function that embeds the input into a vector
from chromadb import EmbeddingFunction
def openai_embed(self, input, api_key, model_name):
openai = EmbeddingFunction.OpenAIEmbeddingFunction(
api_key=api_key,
model_name=model_name
)
embedding = openai(input)
return embedding

@ -1,9 +1,10 @@
#speech to text
#speech to text tool
import os
from pydub import AudioSegment
from pytube import YouTube
import whisperx
import subprocess
class SpeechToText:
def __init__(
@ -30,6 +31,13 @@ class SpeechToText:
self.compute_type = compute_type
self.hf_api_key = hf_api_key
def install(self):
subprocess.run(["pip", "install", "whisperx"])
subprocess.run(["pip", "install", "pytube"])
subprocess.run(["pip", "install", "pydub"])
def download_youtube_video(self):
audio_file = f'video.{self.audio_format}'

@ -1,23 +1,29 @@
import logging
import os
import re
import logging
from pathlib import Path
from typing import Dict, List
from swarms.agents.utils.agent_creator import AgentCreator
from swarms.utils.main import BaseHandler, FileHandler, FileType
from swarms.tools.main import ExitConversation, RequestsGet, CodeEditor, Terminal
from swarms.utils.main import CsvToDataframe
from swarms.tools.main import BaseToolSet
from swarms.utils.main import StaticUploader
from swarms.tools.main import (
BaseToolSet,
CodeEditor,
ExitConversation,
RequestsGet,
Terminal,
)
from swarms.utils.main import (
BaseHandler,
CsvToDataframe,
FileHandler,
FileType,
StaticUploader,
)
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
BASE_DIR = Path(__file__).resolve().parent.parent
# Check if "PLAYGROUND_DIR" environment variable exists, if not, set a default value
playground = os.environ.get("PLAYGROUND_DIR", './playground')
# Ensure the path exists before changing the directory
os.makedirs(BASE_DIR / playground, exist_ok=True)
@ -45,8 +51,14 @@ class WorkerUltraNode:
if os.environ.get("USE_GPU", False):
import torch
from swarms.tools.main import ImageCaptioning
from swarms.tools.main import ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering
from swarms.tools.main import (
ImageCaptioning,
ImageEditing,
InstructPix2Pix,
Text2Image,
VisualQuestionAnswering,
)
if torch.cuda.is_available():
toolsets.extend(

Loading…
Cancel
Save