💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Add additional format support, update comments
davidmezzettibb62355b5369
diff --git a/src/python/txtai/pipeline/audio/transcription.py b/src/python/txtai/pipeline/audio/transcription.pyindex e110eaf1..7ec31f12 100644--- a/src/python/txtai/pipeline/audio/transcription.py+++ b/src/python/txtai/pipeline/audio/transcription.py@@ -35,7 +35,7 @@ class Transcription(HFPipeline):Args:audio: audio|list- rate: sampling rate, only required with raw audio data+ rate: sample rate, only required with raw audio datachunk: process audio in chunk second sized segmentsjoin: if True (default), combine each chunk back together into a single text output.When False, chunks are returned as a list of dicts, each having raw associated audio and@@ -59,11 +59,11 @@ class Transcription(HFPipeline):def read(self, audio, rate):"""- Read audio to raw waveforms and sampling rates.+ Read audio to raw waveforms and sample rates.Args:audio: audio|list- rate: optional sampling rate+ rate: optional sample rateReturns:List of (audio data, sample rate)@@ -74,6 +74,9 @@ class Transcription(HFPipeline):if isinstance(x, str):# Read fileraw, samplerate = sf.read(x)+ elif isinstance(x, tuple):+ # Input is NumPy array and sample rate+ raw, samplerate = xelse:# Input is NumPy arrayraw, samplerate = x, rate@@ -88,7 +91,7 @@ class Transcription(HFPipeline):with the chunk size. Returns text for each input.Args:- speech: list of dicts with raw data and sample rates+ speech: list of (audio data, sample rate)chunk: split audio into chunk seconds sized segments for processingReturns:@@ -109,11 +112,11 @@ class Transcription(HFPipeline):the raw wav snippets.Args:- speech: list of dicts with raw data and sample rates+ speech: list of (audio data, sample rate)chunk: split audio into chunk seconds sized segments for processingReturns:- list of lists of dicts. each dict has text, raw wav data and sample rate+ list of lists of dicts - each dict has text, raw wav data for text and sample rate"""results = []diff --git a/test/python/testpipeline/testtranscription.py b/test/python/testpipeline/testtranscription.pyindex e3c2d5c9..28584af6 100644--- a/test/python/testpipeline/testtranscription.py+++ b/test/python/testpipeline/testtranscription.py@@ -30,6 +30,7 @@ class TestTranscription(unittest.TestCase):# Read audio dataraw, samplerate = sf.read(Utils.PATH + "/Make_huge_profits.wav")+ self.assertEqual(transcribe((raw, samplerate)), "Make huge profits without working make up to one hundred thousand dollars a day")self.assertEqual(transcribe(raw, samplerate), "Make huge profits without working make up to one hundred thousand dollars a day")def testChunks(self):