Add gitignor
This commit is contained in:
70
scripts/list_voices.py
Normal file
70
scripts/list_voices.py
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Liste toutes les voix Voxtral disponibles (preset et custom).
|
||||
|
||||
Usage :
|
||||
python scripts/list_voices.py
|
||||
python scripts/list_voices.py --type preset
|
||||
python scripts/list_voices.py --type custom
|
||||
"""
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from mistralai.client import Mistral
|
||||
from assistant import config
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Lister les voix Voxtral disponibles")
|
||||
parser.add_argument(
|
||||
"--type",
|
||||
choices=["all", "preset", "custom"],
|
||||
default="all",
|
||||
help="Type de voix à lister (défaut: all)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
client = Mistral(api_key=config.MISTRAL_API_KEY)
|
||||
|
||||
page, page_size = 0, 50
|
||||
all_voices = []
|
||||
|
||||
while True:
|
||||
response = client.audio.voices.list(
|
||||
type_=args.type,
|
||||
limit=page_size,
|
||||
offset=page * page_size,
|
||||
)
|
||||
all_voices.extend(response.items)
|
||||
if len(all_voices) >= response.total or not response.items:
|
||||
break
|
||||
page += 1
|
||||
|
||||
if not all_voices:
|
||||
print("Aucune voix trouvée.")
|
||||
return
|
||||
|
||||
# Affichage tabulaire
|
||||
col_name = max(len(v.name) for v in all_voices)
|
||||
col_lang = max(len(str(v.languages or [])) for v in all_voices)
|
||||
col_id = max(len(v.id) for v in all_voices)
|
||||
|
||||
header = f"{'NOM':<{col_name}} {'LANGUES':<{col_lang}} {'ID':<{col_id}} TYPE"
|
||||
print(f"\n{header}")
|
||||
print("-" * len(header))
|
||||
|
||||
for v in sorted(all_voices, key=lambda x: (x.languages or ["zzz"])[0] + x.name):
|
||||
langs = ", ".join(v.languages) if v.languages else "—"
|
||||
voice_type = "preset" if not v.user_id else "custom"
|
||||
print(f"{v.name:<{col_name}} {langs:<{col_lang}} {v.id:<{col_id}} {voice_type}")
|
||||
|
||||
print(f"\n{len(all_voices)} voix trouvée(s).")
|
||||
print("\nPour utiliser une voix, ajoute dans .env :")
|
||||
print(" VOICE_ID=<id>")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user