TASK : with out using (argpars, asyncio), we have develop command line interface 



user_input: text 
return: playsound , audio file




import argparse
import asyncio
import sys
import tempfile
from typing import Dict, Optional

import edge_tts
from playsound import playsound


async def get_voices() -> Dict[str, str]:
    """
    Retrieve all available voices from the edge_tts service.

    Returns:
        A dictionary mapping voice descriptions to their short names.
    """
    try:
        voices = await edge_tts.list_voices()
        return {
            f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName']
            for v in voices
        }
    except Exception as e:
        raise RuntimeError(f"Failed to retrieve voices: {e}")


async def text_to_speech(
    text: str,
    voice: str,
    rate: int,
    pitch: int,
    output_path: Optional[str] = None
) -> str:
    """
    Convert text to speech and save as an MP3 file.

    Args:
        text: The text to convert.
        voice: The selected voice short name.
        rate: Speech rate adjustment in percentage.
        pitch: Pitch adjustment in Hz.
        output_path: Optional path to save the output MP3 file.

    Returns:
        The file path to the generated MP3 audio.

    Raises:
        ValueError: If text or voice parameters are invalid.
        RuntimeError: If TTS conversion fails.
    """
    if not text.strip():
        raise ValueError("Input text cannot be empty.")
    if not voice.strip():
        raise ValueError("A valid voice must be selected.")

    rate_str = f"{rate:+d}%"
    pitch_str = f"{pitch:+d}Hz"

    communicator = edge_tts.Communicate(
        text=text,
        voice=voice,
        rate=rate_str,
        pitch=pitch_str
    )

    try:
        if output_path:
            await communicator.save(output_path)
            return output_path
        else:
            with tempfile.NamedTemporaryFile(
                delete=False, suffix=".mp3"
            ) as tmp_file:
                tmp_path = tmp_file.name
            await communicator.save(tmp_path)
            return tmp_path
    except Exception as e:
        raise RuntimeError(f"Text-to-speech conversion failed: {e}")


def parse_arguments(voices: Dict[str, str]) -> argparse.Namespace:
    """
    Parse command-line arguments provided by the user.

    Args:
        voices: A dictionary of available voices.

    Returns:
        The populated namespace with parsed arguments.
    """
    parser = argparse.ArgumentParser(
        description="Voicecloning.be Text-to-Speech Command-Line Interface"
    )

    parser.add_argument(
        "-t",
        "--text",
        type=str,
        required=True,
        help="Text to convert to speech."
    )

    parser.add_argument(
        "-v",
        "--voice",
        type=str,
        required=True,
        choices=voices.keys(),
        help="Voice to use for speech."
    )

    parser.add_argument(
        "-r",
        "--rate",
        type=int,
        default=0,
        help="Speech rate adjustment in percentage (e.g., -10 for slower, +10 for faster). Default is 0."
    )

    parser.add_argument(
        "-p",
        "--pitch",
        type=int,
        default=0,
        help="Pitch adjustment in Hz (e.g., -5 for lower, +5 for higher). Default is 0."
    )

    parser.add_argument(
        "-o",
        "--output",
        type=str,
        default=None,
        help="Output file path for the generated MP3. If not provided, a temporary file will be used."
    )

    return parser.parse_args()


async def main() -> None:
    """
    The main function to execute the CLI for text-to-speech conversion.
    """
    try:
        voices = await get_voices()
    except RuntimeError as e:
        print(f"Error: {e}", file=sys.stderr)
        sys.exit(1)

    if not voices:
        print("No voices available.", file=sys.stderr)
        sys.exit(1)

    args = parse_arguments(voices)

    voice_short_name = voices.get(args.voice)
    if not voice_short_name:
        print("Selected voice is not available.", file=sys.stderr)
        sys.exit(1)

    try:
        output_file = await text_to_speech(
            text=args.text,
            voice=voice_short_name,
            rate=args.rate,
            pitch=args.pitch,
            output_path=args.output
        )
        print(f"Audio successfully saved to: {output_file}")

        # Automatically play the audio
        try:
            print("Playing the audio...")
            playsound(output_file)
        except Exception as play_error:
            print(f"Failed to play audio: {play_error}", file=sys.stderr)

    except ValueError as ve:
        print(f"Input Error: {ve}", file=sys.stderr)
        sys.exit(1)
    except RuntimeError as re:
        print(f"Processing Error: {re}", file=sys.stderr)
        sys.exit(1)
    except Exception as ex:
        print(f"An unexpected error occurred: {ex}", file=sys.stderr)
        sys.exit(1)


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("\nOperation cancelled by user.", file=sys.stderr)
        sys.exit(1)