main.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * main.cpp
  3. * Copyright (C) 2010 HAL, kbinani
  4. *
  5. * This file is a part of v.Connect-STAND.
  6. *
  7. * v.Connect-STAND is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU GPL License
  9. *
  10. * v.Connect-STAND is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * ---------------------------------------------------------------------
  15. * Mainly, these codes are about File I/O.
  16. *
  17. */
  18. //hack to avoid undefined reference on Trisquel GNU/Linux
  19. #define BOOST_NO_SCOPED_ENUMS
  20. #include <iostream>
  21. #define BOOST_NO_CXX11_SCOPED_ENUMS
  22. #include <boost/filesystem.hpp>
  23. #undef BOOST_NO_CXX11_SCOPED_ENUMS
  24. #include <sstream>
  25. #include "Synthesizer.h"
  26. #include "Converter.h"
  27. #include "Transcriber.h"
  28. #include "EncodingConverter.h"
  29. #include "Configuration.h"
  30. #include <locale>
  31. //#define __TEST__
  32. #define VCONNECT_VERSION "v.Connect-STAND ver2.0.2"
  33. //this version builds on trisquel 8
  34. using namespace vconnect;
  35. int main( int argc, char *argv[] )
  36. {
  37. RuntimeOption option( argc, argv );
  38. if( option.isPrintCodeset() ){
  39. list<string> supportedCodesets = Configuration::supportedCodesets();
  40. list<string>::iterator i = supportedCodesets.begin();
  41. for( ; i != supportedCodesets.end(); i++ ){
  42. string codeset = *i;
  43. if( EncodingConverter::isValidEncoding( codeset ) ){
  44. cout << codeset << endl;
  45. }
  46. }
  47. }
  48. string input = option.getInputPath();
  49. string output = option.getOutputPath();
  50. #ifdef __TEST__
  51. input = "test.txt";
  52. output = "log.wav";
  53. #else
  54. #ifdef _DEBUG
  55. cout << "::main; encodingOtoIni=" << option.getEncodingOtoIni() << endl;
  56. cout << "::main; encodingVsqText=" << option.getEncodingVsqText() << endl;
  57. #endif
  58. if( (input == "" || output == "") && false == option.isPrintCodeset() ){
  59. // ファイルの指定のどちらかが欠けている場合
  60. // 説明文を表示してbailout
  61. cout << VCONNECT_VERSION << endl;
  62. cout << "usage:" << endl;
  63. cout << " vConnect -i [vsq_meta_text_path] -o [out_wave_path] {options}" << endl;
  64. cout << " vConnect [vsq_meta_text_path] [out_wave_path]" << endl;
  65. cout << " or" << endl;
  66. cout << " vConnect -c -i [utau_oto_ini_path] -o [out_stand_path]" << endl;
  67. cout << " vConnect -t -i [src_vConnect_ini_path] -o [dst_vConnect_ini_path]" << endl;
  68. cout << "options:" << endl;
  69. cout << " -i [path] path of input-file" << endl;
  70. cout << " -o [path] path of output-file" << endl;
  71. cout << " -c convert mode" << endl;
  72. cout << " -t transcribe mode" << endl;
  73. cout << " -charset-otoini [charset-name] charset of oto.ini (default: Shift_JIS)" << endl;
  74. cout << " -charset-vxt [charset-name] charset of input-file (default: Shift_JIS)" << endl;
  75. cout << " -list-charset print supported charset list" << endl;
  76. return 0;
  77. }
  78. #endif
  79. #ifdef _DEBUG
  80. cout << "::main; input=" << input << endl;
  81. cout << "::main; output=" << output << endl;
  82. #endif
  83. Task *task = NULL;
  84. if( option.isConvert() ){
  85. task = (Task *)new Converter( option );
  86. }else if( option.isTranscribe() ){
  87. task = (Task *)new Transcriber( option );
  88. }else{
  89. task = (Task *)new Synthesizer( option );
  90. }
  91. if( task ){
  92. task->run();
  93. delete task;
  94. task = NULL;
  95. }
  96. return 0;
  97. }