rick commited on
Commit
00f58d9
·
unverified ·
1 Parent(s): b1de12a

corrections d'erreurs dans le code...

Browse files
Files changed (3) hide show
  1. core/core.py +1 -1
  2. core/speech_to_text.py +4 -6
  3. pages/main.py +1 -1
core/core.py CHANGED
@@ -5,7 +5,7 @@ from os import getenv
5
  #from typing import Any
6
  #from typing import Dict
7
  #from typing import IO
8
- #from typing import List
9
  from typing import Optional
10
  from typing import Tuple
11
  from typing import Union
 
5
  #from typing import Any
6
  #from typing import Dict
7
  #from typing import IO
8
+ from typing import List
9
  from typing import Optional
10
  from typing import Tuple
11
  from typing import Union
core/speech_to_text.py CHANGED
@@ -9,7 +9,7 @@ from io import BytesIO
9
  #from typing import Any
10
  #from typing import Dict
11
  from typing import IO
12
- #from typing import List
13
  from typing import Optional
14
  #from typing import Tuple
15
  from typing import Union
@@ -18,7 +18,7 @@ from core.DetectLanguage import detect_language
18
 
19
  def huggingface_endpoints_stt(fichier_audio: str) -> str:
20
  # Définir l'URL de l'endpoint d'inférence sur Hugging Face
21
- API_URL = f"{getenv("hf_endpoint_whisper_large_v3_turbo")}"
22
 
23
  # Inclure votre token d'accès Hugging Face dans les en-têtes de la requête
24
  headers = {
@@ -186,13 +186,12 @@ class SpeechToText(object):
186
  elif isinstance(filepath, IO):
187
  file_paths = [filepath.name]
188
  else:
189
- file_paths = [ f"{file_path}" for file_path in filepath if isinstance(filepath, List[str]) else file_path.name for file_path in filepath ]
190
 
191
  # create the list 'file_streams'
192
- file_streams = [open(f, "rb") for path in file_paths]
193
 
194
  def create_assistant():
195
- nonlocal self.client
196
  return self.client.beta.assistants.create(
197
  name="Audio Language Detector",
198
  instructions=" ".join([
@@ -209,7 +208,6 @@ class SpeechToText(object):
209
 
210
 
211
  def create_vector_store():
212
- nonlocal self.client
213
  return self.client.beta.vector_stores.create(
214
  name="Audio Language Detection"
215
  )
 
9
  #from typing import Any
10
  #from typing import Dict
11
  from typing import IO
12
+ from typing import List
13
  from typing import Optional
14
  #from typing import Tuple
15
  from typing import Union
 
18
 
19
  def huggingface_endpoints_stt(fichier_audio: str) -> str:
20
  # Définir l'URL de l'endpoint d'inférence sur Hugging Face
21
+ API_URL = f"{getenv('hf_endpoint_whisper_large_v3_turbo')}"
22
 
23
  # Inclure votre token d'accès Hugging Face dans les en-têtes de la requête
24
  headers = {
 
186
  elif isinstance(filepath, IO):
187
  file_paths = [filepath.name]
188
  else:
189
+ file_paths = [f'{file_path}' if isinstance(filepath, List) and isinstance(file_path, str) else file_path.name for file_path in filepath]
190
 
191
  # create the list 'file_streams'
192
+ file_streams = [open(filepath, "rb") for filepath in file_paths]
193
 
194
  def create_assistant():
 
195
  return self.client.beta.assistants.create(
196
  name="Audio Language Detector",
197
  instructions=" ".join([
 
208
 
209
 
210
  def create_vector_store():
 
211
  return self.client.beta.vector_stores.create(
212
  name="Audio Language Detection"
213
  )
pages/main.py CHANGED
@@ -41,7 +41,7 @@ from core.converter import convert_language_name_to_iso6391
41
  from core.files import read_file
42
  from core.text_to_speech import openai_tts
43
  from core.DetectLanguage import detect_language
44
- from core.speech_to_text import huggingface_endpoints_stt
45
  from core.speech_to_text import transcribe_audio
46
  from core.audio_files import concatenate_audio_files
47
  from core.audio_files import split_audio
 
41
  from core.files import read_file
42
  from core.text_to_speech import openai_tts
43
  from core.DetectLanguage import detect_language
44
+ #from core.speech_to_text import huggingface_endpoints_stt
45
  from core.speech_to_text import transcribe_audio
46
  from core.audio_files import concatenate_audio_files
47
  from core.audio_files import split_audio