app.py 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #!/usr/bin/env python3
  2. import sys
  3. import platform
  4. print("[info] Starting Lyrebird v1.2.0")
  5. major = sys.version_info[0]
  6. minor = sys.version_info[1]
  7. # Check for Python 3.7+
  8. if major < 3 and minor < 7:
  9. print("[error] Python 3.7 or higher is required to run Lyrebird")
  10. input("Press return to exit...")
  11. sys.exit(1)
  12. platform_sys = platform.system()
  13. # Keeping it open to other NIXes!
  14. if platform_sys == "Windows" or platform_sys == "Darwin":
  15. print("[error] Linux is required to used Lyrebird")
  16. input("Press return to exit...")
  17. sys.exit(1)
  18. from app.core.launch import Launch
  19. # Check for Python gobject installation
  20. if not Launch.check_py_gtk():
  21. msg = '''[error] Python GTK is missing from your system.
  22. * On Debian, Ubuntu, pop_OS, or Mint, try running: sudo apt install python3-gi
  23. * On Arch, try running: sudo pacman -S python-gobject
  24. * On all other distros, this package may have a different name, try searching for "python3 gtk installation instructions".
  25. Additional help can be found in the Lyrebird repo: https://github.com/lyrebird-voice-changer/lyrebird/issues
  26. '''
  27. print(msg)
  28. input("Press return to exit...")
  29. sys.exit(1)
  30. # Import GTK
  31. import gi
  32. gi.require_version('Gtk', '3.0')
  33. from gi.repository import Gtk
  34. if __name__ != '__main__':
  35. sys.exit(0)
  36. from app.ui.alert import Alert
  37. # Check for pactl
  38. if not Launch.check_pactl():
  39. console_msg = '''[error] PulseAudio utilities are missing from your system.
  40. * On Ubuntu, Debian, pop_OS, or Mint, try running: sudo apt install pulseaudio-utils
  41. * On Arch, this comes with the package "pipewire-pulse", please refer to the Arch Wiki page (below).
  42. * On all other distros, this package may have a different name, try searching for "pactl" or "pulseaudio utilities".
  43. If after installing PulseAudio utilities and you still see this error, or your distro does not contain an equivalent package, your audio server may be configured in a way that is incompatible with Lyrebird. The "pactl" command is required for Lyrebird.
  44. Additional help can be found in the Lyrebird repo: https://github.com/lyrebird-voice-changer/lyrebird/issues
  45. Arch Wiki PipeWire page: https://wiki.archlinux.org/title/PipeWire (for Arch users)'''
  46. print(console_msg)
  47. msg = '''<b>Error:</b> PulseAudio utilities are missing from your system.
  48. On Ubuntu, Debian, pop_OS, or Mint, try running:
  49. <i>sudo apt install pulseaudio-utils</i>
  50. On Arch, this comes with the package <i>pipewire-pulse</i>, please refer to the <a href="https://wiki.archlinux.org/title/PipeWire">Arch Wiki page</a>.
  51. On all other distros, this package may have a different name, try searching for "pactl" or "pulseaudio utilities".
  52. If after installing PulseAudio utilities and you still see this error, or your distro does not contain an equivalent package, your audio server may be configured in a way that is incompatible with Lyrebird. The "pactl" command is required for Lyrebird.
  53. Additional help can be found in the <a href="https://github.com/lyrebird-voice-changer/lyrebird/issues">Lyrebird repo</a>.'''
  54. alert = Alert(None)
  55. alert.show_error_markup("Lyrebird Error: PulseAudio utilities are missing", msg)
  56. sys.exit(1)
  57. # Check for TOML
  58. if not Launch.check_py_toml():
  59. console_msg = '''[error] Python module "toml" is missing from your system.
  60. * On Ubuntu, Debian, pop_OS, or Mint, try running: sudo apt install python3-toml
  61. * On Arch, try running: sudo pacman -S python-toml
  62. * For all other distros, try running: pip3 install toml
  63. Additional help can be found in the Lyrebird repo: https://github.com/lyrebird-voice-changer/lyrebird/issues'''
  64. print(console_msg)
  65. msg = '''<b>Error:</b> Python module "toml" is missing from your system.
  66. On Ubuntu, Debian, pop_OS, or Mint, try running:
  67. <i>sudo apt install python3-toml</i>
  68. If you're using Arch, try running:
  69. <i>sudo pacman -S python-toml</i>
  70. For all other distros, try running:
  71. <i>pip3 install toml</i>
  72. Additional help can be found in the <a href="https://github.com/lyrebird-voice-changer/lyrebird/issues">Lyrebird repo</a>.'''
  73. alert = Alert(None)
  74. alert.show_error_markup("Lyrebird Error: Python TOML is Missing", msg)
  75. sys.exit(1)
  76. # Check for SoX
  77. if not Launch.check_sox():
  78. console_msg = '''[error] Shell command "sox" is missing from your system.
  79. * On Ubuntu, Debian, pop_OS, or Mint, try running: sudo apt install sox libsox-fmt-pulse
  80. * On Arch, try running: sudo pacman -S sox
  81. * For all other distros, try searching for the package "sox".
  82. Additional help can be found in the Lyrebird repo: https://github.com/lyrebird-voice-changer/lyrebird/issues'''
  83. print(console_msg)
  84. msg = '''<b>Error:</b> Shell command "sox" is missing from your system.
  85. On Ubuntu, Debian, pop_OS, or Mint, try running:
  86. <i>sudo apt install sox libsox-fmt-pulse</i>
  87. If you're using Arch, try running:
  88. <i>sudo pacman -S sox</i>
  89. For all other distros, try searching for the package "sox".
  90. Additional help can be found in the <a href="https://github.com/lyrebird-voice-changer/lyrebird/issues">Lyrebird repo</a>.'''
  91. alert = Alert(None)
  92. alert.show_error_markup("Lyrebird Error: sox is missing", msg)
  93. sys.exit(1)
  94. if not Launch.check_sox_pulse():
  95. console_msg = '''[error] SoX is missing the PulseAudio audio driver.
  96. * On Ubuntu, Debian, pop_OS, or Mint, try running: sudo apt install libsox-fmt-pulse
  97. * For all other distros, try searching for the the installation of "sox pulseaudio audio driver".
  98. Additional help can be found in the Lyrebird repo: https://github.com/lyrebird-voice-changer/lyrebird/issues'''
  99. print(console_msg)
  100. msg = '''<b>Error:</b> SoX is missing the PulseAudio audio driver.
  101. On Ubuntu, Debian, pop_OS, or Mint, try running:
  102. <i>sudo apt install libsox-fmt-pulse</i>
  103. For all other distros, try searching for the the installation of "sox pulseaudio audio driver".
  104. Additional help can be found in the <a href="https://github.com/lyrebird-voice-changer/lyrebird/issues">Lyrebird repo</a>.'''
  105. alert = Alert(None)
  106. alert.show_error_markup("Lyrebird Error: SoX PulseAudio audio driver missing", msg)
  107. sys.exit(1)
  108. audio_server = Launch.determine_audio_server()
  109. print(f"[info] Audio server: {audio_server}")
  110. from app.ui.mainwindow import MainWindow
  111. # Start main window and launch Lyrebird
  112. win = MainWindow()
  113. win.connect('destroy', win.close)
  114. win.show_all()
  115. try:
  116. Gtk.main()
  117. except BaseException as e:
  118. print(e)
  119. msg = f'''<b>Fatal Lyrebird Error:</b> {str(e)}
  120. Please report to the <a href="https://github.com/lyrebird-voice-changer/lyrebird/issues">Lyrebird repo</a>.'''
  121. alert = Alert(None)
  122. alert.show_error_markup("Fatal Lyrebird Error", msg)
  123. win.close()